1

How can I determine how many workflows were run in 2015 on my SharePoint 2007?

Thanks for any assistance!

2

First off I am going to offer some apologies as the solution I am going to provide may be a bit off as I have done very little custom dev with SP2007 so please bear with me and if something doesn't make sense then please ask. My solution makes the assumption that all of your workflows write to the default Workflow History list and not a custom list.

You are going to want to create a console\batch app for this. Every workflow that is created in a site has a GUID based ID. So basically this solution is going to get all of the history for the year and then get the number of distinct entries for the field to get you that count.

For each site you are going to want to create an SPQuery object that looks something like this:

<Where>
  <Geq>
     <FieldRef Name='Created' />
     <Value IncludeTimeValue='TRUE' Type='DateTime'>2015-01-01T09:27:54Z</Value>
  </Geq>
</Where>

This will get you the list of items that were created in the year for that site.

Next run the code to get the data you need from the site's workflow history list:

using(SPSite spSite = new SPSite("site url"))
{
  using(SPWeb spWeb = spSite.RootWeb)
  {
    SPList wfHistList = spWeb.Lists["Workflow History"];

    //use the query above (created into an SPQuery object) to populate a datatable
    DataTable allItemsTable = wfHistList.GetItems(spQuery).GetDataTable();

    //create a new view against that table and move the items into the new table
    DataView distinctView = new DataView(allItemsTable);
    //It needs to be against the internal name of the Workflow History Parent Instance column
    String[] distinctColumn = {"WorkflowInstance"};

    //you can now create a datatable using the view as true indicates you only want the distinct items.
    DataTable distinctItemsTbl= distinctView.ToTable(true, distinctColumn);
  }
}

So you can now handle this as you will. Add that to a master table or output per site, but either way, your distinctItemsTbl should only have a single row for each Workflow created in your Workflow History list.

I strongly suggest you do not run this during peak hours as it could definitely affect performance.

Hope this helps.

  • Thanks for the information. I do not have session access to the server(s) – richard williams Apr 28 '16 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.