Vadim Tabakman

An interesting topic arose on Nintex Connect, regarding having the same workflow on a number of lists and libraries, and how one would go about updating all of them. This is especially important, given that in the SharePoint 2007, you can't create a declarative workflow for a Content Type.

You could create a workflow, save it as a template, and then create workflows on all your other lists/libraries based on this template. But the issue is, there's no way to update this in a central place, that would then go and update all the other workflows you created from this template.

Idea

Most companies have QA/Test environment where the workflow is designed, and then once they are happy with it, they push that workflow into their production environment. So I'm going to use a similar design.

I am going to have a central place/site where I create workflows, then once I am happy with it, I will export it through the Nintex Workflow Designer to a NWF file.



I have one List which will be treated as a Lookup list. It will contain the name of the workflow I should look for, and the destination list that needs updating, and also what the workflow is named on that destination list. SharePoint has a limitation that you can not use the same workflow name multiple times in the same site.

I will then have a Document Library where I will upload my exported NWF file and a workflow will start off that will figure out what lists/document libraries require this workflow to be published on.

Lookup List name : Workflow to List Map
Workflow Document Library : Master List of Workflows
eg. List to be updated : List1
eg. Document Library to be updated : DocumentLibrary1

Main List and Document Library

The Master List of Workflows document library will be the location where you would upload your Nintex Workflow export file (NWF).



As you can see, there is nothing special with this document library. It will only hold the NWF files.

The Workflow to List Map list, is a little different. This is a standard SharePoint Custom List, where I have renamed the Title field to "Workflow Name", and added 2 Single line of text fields (Destination Workflow Name and List Name).



The List1 and DocumentLibrary1, are just a simple List and Document Library, where I want to publish my workflow/s.

The Workflow

In the screenshot above, for my "Workflow to List Map" list, I have added 2 entries. Both are for the workflow file named "SimpleWorkflow.nwf". The first entry is telling us that that workflow should be updated in the List "List1" and the name of the workflow should be "Simple List Workflow".

The second entry is for the same workflow filename, and this time we are updating a list (document library) named "DocumentLibrary1", and call the workflow "Simple Document Library Workflow".

I won't focus on how to export a workflow. Suffice it to say, I create a simple workflow with just a Log in the History List action in it.



Once you upload your NWF file to the "Master List of Workflows", this workflow will start.

You can see that it is not a very complicated workflow. The pseudo-logic is below :
1. Query the Workflow to List Map list, for all List Names where the "Workflow Name" matches the uploaded NWF filename.
2. Query the Workflow to Lsit Map list, for all Destination Workflow Names where the "Workflow Name" matches the uploaded NWF filename
3. Use the Query XML action, to get all the XML of the NWF file
4. XML Encode the XML we have retrieved. (I didn't use the fn-XmlEncode inline function, because I had some issues with it).
5. Loop through the List of destination List Names, and publish this this workflow.

Looking a little deeper into the For Each action, we see the following :



What I am doing here, is iterating through my collection of destination List Names, and the getting the associated Destination Workflow Name from my other collection variable.

Then we have the important part, which is calling the Nintex Workflow web service. This you can find here : http://<server>/<site>/_vti_bin/NintexWorkflow/Workflow.asmx

This web service exposes a number of web methods, but the one I was most interested in for this issue, is the PublishFromNWFXml method. This method takes the NWF Xml that XML Encoded earlier, the destination List Name and the Destination Workflow Name (also a saveIfCannotPublish parameter, which I just set to true).



I complete the For Each action, by using a Set a Condition action, to check if the Call Web Service action completely successfully or not. If it hasn't, I email the Initiator of the workflow, the data that was returned to us from the Web Service, and also any error that was caught. That way, the Initiator of the workflow will know something has failed, and also know the reason and can fix it, and restart the workflow.

What happens when the workflow runs?

When we run the workflow on the uploaded NWF file, the workflow will then publish this workflow on the destination Lists and Document Libraries. You can tell, by going to one of the destination lists, and going to Manage Workflows :



When the page comes up, you'll see that the newly added workflow is a Published state.



This workflow should have the name, as specified by its entry in the Workflow to List Map list. It will also has the same Startup Options as the workflow that you exported. So if you want this workflow to start when items are created, make sure you set that setting on the workflow you designed, prior to exporting it.

In Conclusion

This is one way of making sure a workflow that you want on a number of lists and document libraries get published on those lists from a central source. This will also update any existing workflows. So if you already have a workflow named Simple Lsit Workflow on your destination list, this process will update that workflow (including the version).

Downloads

 Nintex Workflow 2007

 Test Workflow Design: Download Update Workflows workflow

Posted by Vadim Tabakman Sunday, February 5, 2012 9:51:00 PM Categories: Call Web Service For Each Nintex Nintex Workflow PublishFromNWFXml Query List Set a Condition
Copyright Vadim Tabakman
Rate this Content 2 Votes

Comments

Thursday, August 23, 2012 3:45:34 PM
Jim Oleson

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi V!

An important note for 2010 - I have found that the simple encode causes the publish method to fail. It looks like the web service does that for you now. Can you confirm? Otherwise, this works great and saved me a ton of time in 2007!! Thanks!

 

Jim

Friday, August 24, 2012 7:20:05 AM

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi Jim,

thanks for letting me know about that.  I'll play with it for NW2010.  I'm pretty sure you're right though.

cheers,

Vadim

Friday, April 12, 2013 8:27:20 AM
unknown

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi Vadim,
I just wanted to tell you how SUPER THRILLED I am with this procedure!!  I tweaked mine quite a bit to suit my requirements, but the base procedure is AMAZING.  I set up a few startup page variables to really gain control over the procedure by loading choice variables and building arrays.  One is a multi-select choice of libraries to update.  I also have a choice on which type of workflow to update (I have 2 workflows per library).  Third, I set up a choice to run in Testing mode (to check and see if all the values are valid) or Deployment mode where it actually updates and publishes the appropriate XML, which gives me email notifications stating exactly what's going on.  I tested it every which way, and it ROCK SOLID now.   THANK YOU for the great method!!  It is exactly what I needed, and saves me a ton of time and headaches! Laughing

Nick Lechnir

Friday, April 12, 2013 9:36:34 AM

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

That's awesome Nick.  I like the way you've enhanced the process.  That's amazing!!

I'm glad this helped you.

Friday, June 21, 2013 12:45:01 AM
Rajesh

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi Vadim,

             This is nice post. I have requirement in other way, Can you please suggest the way to follow. I have to submit multiple items to list. But only one mail has to trigger to approver, and all items has to list in table manner in the mail. Then approver has to choose at a time that which has to approve and which has to be reject.

Friday, June 21, 2013 7:05:07 AM

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi Rajesh,

A task is really only lnked to one item or document.  You could do a Query List to pull out information on multiple items, then go through the result collections and build up a HTML table and insert that into the email that gets sent out for the task, but that task will only be linked to the item or document the workflow ran on.

Do you mean that from the list, the approver can approve some items and reject others?  I'm not sure how you would do this with developing a custom form.

cheers,

Vadim

Friday, March 7, 2014 4:22:48 AM
Alan Paternoster

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi Vadim,

I like this post very much. I spoke to you via a support call a couple of years ago about updating hundreds of "out there" workflows but I suspect you will not remember.

Can you answer a question for me please?
I have requirement just like this but I need to target one list in each subsite of a site. The subsites are all in the "sites" directory below the site where I have built these lists and workflow of yours. There are 1500+ sites and each has a list and one workflow I need to update (actually there are about 20 lists and as many workflows but I only need to update one at the moment). Will this work (I have not tried it yet as it's a live environment) or will I have to modify the code in some way adding a foreach type function for all the subsites??

I did previously build a c# console app that used the nintex webservice and that worked fine couple of years back but now I get an error saying each workflow is checked out or locked and it fails. I am working back at that same client which does have a support agreement with nintex, but thought i'd post it here because the answer may be useful for others regarding subsites.

Thanks,

Alan

Wednesday, May 27, 2015 8:04:11 AM
Manisha
Gravatar

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hello Vadim,

 

This is a fantastic post. Thanks!

However, my requirement is a next step to this. I have to publish workflows to lists/libraries in other sites and not in same site.

Could you suggest any idea how this can be accomplished.

 

Regards,

Manisha 

Wednesday, May 27, 2015 8:13:11 AM

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hi Manisha,

this will work in your requirement also.  In the Call Web Service action, you need to make sure the URL to the web service, contains the url to the site where you want to publish the workflow.

eg.

if this workflows run on http://mysharepoint/development  but you want to publish the workflows in http://mysharepoint/finance, then your web service url should look like this:

 

http://mysharepoint.com/finance/_vti_bin/NintexWorkflow/Workflow.asmx

cheers,

Vadim

Monday, February 29, 2016 10:02:40 AM
Thomas
Gravatar

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Thank you Vadim!

This is once again a very useful piece of workflow from you. It is saving me lot of time publishing workflows.

Jim Oleson mentioned in his comment that Web Service option "Encode inserted tokens" would do the encoding in SP2010.
I tested it and while I could publish/update the workflows it produced some unexpected results with the items behavior.
I used the inline function fn-XmlEncode and this seems working fine so far.

Thanks again.

Thomas

Monday, February 29, 2016 10:50:32 AM

re: Nintex Workflow - Automatically Updating the "same" workflow on Multiple Lists/Libraries

Hey Thomas,

thanks for the update on the fn-XmlEncode.  I'm glad that helped.

cheers,

Vadim

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

Statistics

  • Entries (279)
  • Comments (1769)

Categories