I'm trying to get the internal status of all sharepoint workflows.
Is there anyway to programmatically query for all workflows, and get their status? Either through a CAML query or the the object model?
I realize that I can iterate over all items in sharepoint, and see if there is a workflow attached, and then get the status. However, that is overkill, as there are 100,000s of items, and only a small subset have workflows. I want to run a periodic report to fetch the status of all workflows, without bringing the server to it's knees.
Thanks!
Dave
Best Answer
A view is, at its heart, a CAML query. The comment from @pst is a good choice if you don't want to iterate through all the items; just swipe the CAML from the view definition of any view that shows the workflow status column. The Lists.asmx Web service could come in handy here, though I usually use PowerShell on the server to extract view definitions.
If you do iterate through the items in the object model, here's a snippet to get rolling: