1
votes

How can I find out the duration of a SharePoint workflow? (IE: How long that workflow took to run from initialization to end?)

I could take the item created by date and subtract it with the date today, but that won't work because the workflow can be started manually.

What's the best way of achieving this. Please, no "SharePoint designer workflow" solutions - this is a visual studio workflow.

2

2 Answers

0
votes

Use a metadata column on your list item to track start and end time of the workflow -- which the workflow can set whenever you want during execution.

A designer workflow could also use the same technique, for others who might view this.

If you need to eliminate the possibility of someone manually editing the workflow history you create this way, just use an account with elevated privileges (or use an impersonation step if using SPD) to write to a list that contributors don't have access to.

1
votes

About ticks: “A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond, or 10 million ticks in a second.” (Microsoft.com: http://msdn.microsoft.com/en-us/library/system.datetime.ticks(v=vs.110).aspx )

Here are your formulas:
Seconds: [Ticks] / 10,000,000
Minutes: [Ticks]/ 600,000,000 or [Ticks]/ 10,000,000/ 60
Hours: [Ticks] / 36,000,000,000 or [Ticks] / 10,000,000 /60 / 60
Days: [Ticks]/864,000,000,000 or [Ticks] / 10,000,000 /60 / 60 / 24