my name is Ollie and I'm working since a half year with Nintex Workflows and Forms .I like them, but I'm tired of clearing the History every week. Especially when using the "Filter" actions the History is getting full and the WFs are getting in stuck.
So I couldn't find s.th how to clear the history automatically, i decided to make a Workflow clearing the History automatically (may be there is somewhere a tutorial but i didn't find it!?).
Now that is I made it with an time scheduled Workflow:
1. Create an new Site Workflow with the following Variables:
- List (String)
- Yesterday (Date)
- ID (String OR Number)
- Index (Number)
2. Now that is how you should arrange the Items in your Workflow
3. Now you should go to the calculate Date and Calculate how Old the Entries should be to be deleted
4. Go to " 'Site Settings' --> 'Manage workflow history lists' " (or you can type into your Browser "YOUR TEAMSITE/_layouts/15/NintexWorkflow/ManageHistoryLists.aspx") and copy the History List Name from these Lists you want to delete automaticaly like shown into the Regular Expression.
5. Create a For Each Loop through the List_Collection an store the Value into the String-Variable List
6. Now it's getting tricky, build the Query with the CAML editor
When you Copy this Query the Workflow will store all ID's into the ID_Collection from entries older than 1,5 days (or how ou had set it up before in the calculate date). Please watch out that everything should be same like shown above, especially with the "List Title" (by default it's "List ID"). If you want to query another field than Modified or Created dont't forget to change the Value Type. To avoid Problem with the Query on List with more than 5.000 entries put the <ViewAttributes Scope="Recursive"> flag to your Query.
7. Optional: Count the Amount of Value's in the ID_Collection an store the Value in the Index variable. Now build a Runf If and here you can define how many Value's there should be in a list for minimum to delete. Put the loop from the next Step inside this Run if
8. Build a For Each Loop from the ID Collection and store each value in the ID Variable.
9. Now we need the Delete Multiple Values action and use there the CAML editor too.
Type in the Query exactly like shown above.
Now that's it from building the workflow. Now you can publish it and add as a time scheduled workflow.
You'll never have an overfilled History again.
Of course you can query by other values too. I'm often using the filter action, wich can't hide from the history. So I make a query by "The item under workflow did not meet the filter criteria." from the field "Description" too.
Heres is this Query-example
Please let me know if this tutorial was helpfull for you. If necessary I can make some several other tutorials too.
If yout got some Questions please put it in the Comments.
With Kind Regards