Vadim Tabakman

Jump to bottom

Nintex Workflow - Archiving a List Item with Workflow History

When you copy an item in SharePoint to another list, you lose the workflow history. The main reason, is that the workflows that ran on the original item, don't exist in the destination list.  Workflow history is linked to a specific workflow instance.

The process described in this post, is about getting the workflow history from an original item and specific workflow instance, and logging it to another workflow instance on the destination item.  Not the ideal solution, but it's better than nothing right?

What I've done though, is add the Workflow History logging into a User Defined Action.  That way, it is reusable in any workflow.  It also means you can reuse it multiple time in one workflow, to copy workflow history from multiple workflow instances.

There are number of ways to get this done.  In this example, the business process (workflow) executes all the actions it needs.  In the end of the workflow, it copies the current item to another list.  But there is one final action. It starts a workflow on the newly copied item.  It's not a matter of just starting a workflow.  That workflow must take some input parameters (start variables).  These include the initial List Name, the initial Item ID and the current Workflow Name.  This is enough information for the destination workflow to then get the Initial workflows history, parse it and store in the new item.

The workflow above is a generic approval process.  But at the end of it, you'll see the Copy Item and the Call Web Service action.  In order to start a workflow on the new item that was copied, those parameters that we pass in, are passed through a piece of XML called Association Data.

The nodes inside the Data node are named, based on the Start Variables in the destination workflow that we are starting.

The Call Web Service, to start a workflow on the new item, call the Nintex Workflow web service.

Notice above, that the destination list where our item exists, is called Archive.  This can be changed to your destination list.  The destination workflow, I've named "Get Source Item Workflow History Workflow".  Finally, we put in our variable that contains the XML association data.  Don't forget to check the box "Encode Inserted Tokens".

Now it's time to take a look at the workflow that runs on that destination copied item. 

The workflow is very simple.  You can of course extend this, because all it has is one action.  A User Defined Action is being used here.  So lets move to the UDA and see what makes up the logic of that.

This is not a complex User Defined Action.  This action has the same parameters as the workflow that is calling it.  The List name, Item ID and workflow name.  It then uses a Call Web Service action to again, call the Nintex Workflow web service, but this time we are calling the GetWorkflowHistoryForListItem.  This will get all the workflow history for that item, for a specific workflow. 

The results that come back are in XML form.  So we use the Query XML action to pull the data out that we need.

I do want to point out that workflow history is stored based on a specific workflow instance.  This process is going to take that workflow and now log it to a different workflow instance.  But that is the result of this process.  There's no way to copy a workflow instance completely over to another list and another list item.  Hopefully, this is a nice workaround for you.

Downloads

Nintex Workflow 2013

Download the User Defined Action (nwf) :   Download and import into the Nintex Workflow Create User Defined Action Designer page

Download the Workflow (nwf) - Download and import into the Nintex Workflow Designer page

Download the Source Workflow - fake business process (nwf) - Download and import into the Nintex Workflow Designer page

Posted by Vadim Tabakman Wednesday, September 23, 2015 1:21:00 PM Categories: Build Dynamic String Call Web Service For Each Log in the History List Query XML StartWorkflowOnListItem
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Tuesday, November 24, 2015 9:37:37 PM

re: Nintex Workflow - Archiving a List Item with Workflow History

Great article, save my efforts. Awesome, keep it up.

Thursday, June 9, 2016 12:31:09 PM
brad
Gravatar

re: Nintex Workflow - Archiving a List Item with Workflow History

When I try to upload the UDA it tells me it's a NWF file and can't be uploaded.  If I change the ".nwf" extension and try to open it in workflow designer it tells me it's UDA and can't be imported.   Something is amiss.

 

Brad

Thursday, June 9, 2016 12:34:46 PM

re: Nintex Workflow - Archiving a List Item with Workflow History

Hi Brad,

don't upload it when you are in the Manage User Defined Actions page.  Instead, on that page, click in Create (or New) and when the designer comes up for a UDA, then click on Import and import it there.

cheers,Vadim

Thursday, June 9, 2016 2:44:58 PM
Vignesh Natarajan
Gravatar

re: Nintex Workflow - Archiving a List Item with Workflow History

Hi Vadim,

 

Greetings! I am looking a similar idea like this where i want to copy a list item instead of document. Is there any way we can copy a list item with version history.. because we have a multi lines of text field in the source  list. when we simply copy the item, it only shows latest value of the mulitiple line field. so the other lines of its initial version of the item are not getting copied.

Will be very happy if i get back from you..

thanks,

vignesh Natarajan

Thursday, June 9, 2016 2:51:39 PM

re: Nintex Workflow - Archiving a List Item with Workflow History

Hi Vignesh,

this example is with a List Item :)

But, I've not seen how to copy and item and preserve version history.

cheers,

Vadim

Thursday, May 18, 2017 8:59:42 AM

re: Nintex Workflow - Archiving a List Item with Workflow History

Hey Vadim,

 

Wondering if the theory behind this UDA can be applied to copying a list item to another list and copying over the version history for each item.

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register
  • RSS





 

Statistics

  • Entries (239)
  • Comments (1725)

Categories