Some thoughts on programming stuff

Export Workflow History to CSV in SharePoint

Sometimes you may need to export Workflow History to CSV in SharePoint, just because most of the history data is not available anymore in the Workflow History page of a document or item, thanks to the SharePoint Workflow Auto Cleanup that purges the data for performance purposes.

But what happens if someone is trying to make an audit review and cannot find the history for a specific document? Well… you can use this script!

Export Workflow History to CSV in SharePoint - Audit and reporting of document history
Audit and reporting of document history
Pxhere

The script to export workflow history

The Script will export the data from the SharePoint list that contains the Workflow history, organizing them in columns:

WorkflowItemID: the numeric id for the list item inside the Workflow History list;
ItemID: the numeric id for the list item that the Workflow ran;
List: the GUID that identifies the List the Workflow ran;
WorkflowInstance: the GUID that identifies the instance of the Workflow that started and finished;
WorkflowAssociation: the GUID that identifies the association of a Workflow with a List;
WorkflowTemplate: the GUID that defines the Template of the Workflow;
UserID: the numeric identifier of a SharePoint user that performed an action in the Workflow;
UserName: the user display name;
UserLogin: the user login account;
OccurredDate: the date and time that event occurred;
Event: the type of event that happened that you can check in Microsoft Docs;
Group: the group of event that happened;
Outcome: the outcome from the action when it applies;
Description: the description of the event that happened;
Data: any additional data for that event.

In conclusion, this script let’s you export the entire workflow history. I hope this script can help when you need to export Workflow History to CSV in SharePoint and preparie some auditing reports to identify what happened to a workflow in a distant past!

Furthermore, you can check other posts related to some PowerShell solutions!

References:
SPWorkflowHistoryType – Microsoft Docs;
Workflow History Event Type Numbers decoded;
Recovering Workflow History after 60 days.

2 Comments

  1. Jeremie Bergeron

    Hi,
    Do you know how to export the data in the page “Workflow Details”?

    Especially the section Task History?

    • Wiliam Rocha

      Hmm, I created once a Console Application in C# that exported these details for me.
      Let me know if you would be interested in something like that.

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2024 wiliammbr's blog

Theme by Anders NorenUp ↑