Nintex Workflow – Workflow Re-use without Templates and Snippets – Part 3
From our previous article – Nintex Workflow – Workflow Re-use without Templates and Snippets – Part 2, we now have a defined piece of work that needs to be done, and we believe that it is something that can be reused by other workflows. We have built a workflow that will perform this functionality in a dynamic way, such that given the necessary information, this piece of work will be done for us.
To reiterate our original goal :
We want to take a semi-colon delimited text string of colors, and use it update a Lookup field that is looking up a Colors SharePoint List.
We have our workflow, sitting the “Reusable Workflows List”. Now we want to call this workflow.
On my list, I’m going to create a workflow. It may have a lot of business logic in it, but in this example, all we will do, is read a Single Line of Text field, and then ask our reusable workflow to update our Colors Lookup field.
I have decided to use the Run Parallel Actions action. On the left branch, I am calling the Nintex Workflow Web Service (StartWorkflowOnListItem), and on the right branch, I am going into a loop, and periodically checking to see if my Colors lookup field has been updated.
The Call Web Service call
To pass the Start Data values to the reusable workflow, we first need to build up the Association Data that will be used in the web service call. For more information about the Association Data, download and look this up in the Nintex Workflow SDK
You can see that we are passing into the Association Data, the name of our lookup list “Lookup Colors”, our current list, which is what the reusable workflow will update, the semi-colon delimited colors which is in our current item, the item ID we are working with so the reusable workflow knows which item to update, the field to update, and finally the name of the field in the Lookup list.
Running the reusable workflow should have the following effect :
It should take the value in the “Colors Text Value” field, and update the “Colors” field which is a lookup.
Now that we have our call to the reusable workflow running on the left branch of the Run Parallel Actions action, on the right we want to wait until it is complete. The way I have implemented this (and this is by far not the only solution), is that I go into a loop and periodically check to see if the “Colors” field has changed from what it was when this workflow started.
My first action in my workflow, is to get the value or the “Colors” field and store it in a Text Workflow Variable. My Loop action is configure to continue looping while the “Colors” field equals my text variable. As soon as the reusable workflow updates the “Colors” field, my loop will complete, and my Run Parallel Actions action will complete.
If you create some complex reusable workflow functionality that you can put into such a workflow, then the size or your calling workflows will reduce. The future maintenance of those workflows will be much easier and faster.
Lookup Colors list template
Reusable Workflows List list template
Test Update Lookup Field list template
Reusable Workflow (import this into the Reusable Workflows List)
Client Workflow that calls the Reusable Workflow (import this workflow into the “Test update Lookup Field” list