You might remember my previous post where I illustrated how you can dynamically build a list of approvers and assign tasks to them in a loop via a Nintex® Workflow. In this post I've included an example .
Step 2: Assigning Tasks for each Brand Dynamically:
This is the second and final state of my workflow and it has the following configuration:
Here I set my workflow status column to:
" Assigning Tasks "
The next step is a For Each which will allow us to iterate through the information returned in our step in our Initial State.
This step is configured as follows:
- Here I basically iterate through my collBrandID collection which stores all of the ID's of my Brands in the Approval Matrix list.
- I then set my Output value to a variable called BrandID to store the current brand I am iterating through in the loop.
- I keep track of each Brand ID in a variable called BrandIndex (which automatically changes when the For Each iterates to the next BrandID)
Just a couple of notes on collections:
- Collections ALWAYS have an Index beginning at 0
- Collections store multiple values into a single collection variable. When I think of collections I think of data been stored in a block. For example a collection containing 3 brands would look like:
And if we put the index next to each Brand Name(and applying the rule that indexes begin at position 0)
Weetbix is at position 0
Kellogs is at position 1
So we can at any time pull out a specific value (using a Get Item from Collection action) OR iterate through all the data using the index to help us keep track of each value in the collection using a For Each action, which automatically increments the index for us as it reads each value out of the collection.
- In this step i get the ID of each Brand because its Unique, meaning that you'll never get items with the same ID in the SAME list
- Collections store multiple pieces of information, which are usually separated with a semi colons or in some cases commas (i.e. " ; " or " , ") and square brackets (i.e. " [ " or " ] " ). This makes it easier for Nintex Workflow to separate each piece of data when we iterate through it or pull out a specific value.
In this step based on the Index, I read the each item out my collection and get the corresponding Brand Name. Remember in my For Each i get the Brand ID and iterate through those
This runs in the loop and will repeat x number of times, where x is the number of items we find.
|In this step for record purposes, I log the current Brand Name and the Brand ID that the workflow has picked up|
Here I query my Approval Matrix list where I take the current Brand ID, to query my Approval Matrix and return in collection variables:
- Approver Name for the specific Brand
- The name of the Deputy for that specific Brand
We're using the Brand ID as a filter which is Unique, and will ensure that for the Approver Name and the Deputy; although both are stored in collection variables; there will be one value for each, and because we expect one value, that value will always have an Index of 0 .
I then log the following to my workflow history (for record purposes):
- Brand Name
1. I use a Parallel Block to run the next set of steps at the same time, in this example this is perfect, as the SAME steps need to occur for both the Approver and the Deputy we pick up when we query our Approval Matrix.
Parallel blocks are great for structuring your workflow, but also ensuring that things happen at the same time, in my example I used this for that purpose but also to make it easier for me to explain the workflow.
2. I then(for both the Approver and the Deputy) take the collection variable(s) returned and set them to their corresponding text variables (I use this data later on in my regular expressions below).
3. In this first regular expression I remove the square brackets that are part of my collection where I return the Approver Name as well as the Deputy. I replace these with blank text. I set the following configuration:
4.In this second regular expression I take the result returned above and replace my commas with semi colons. I do this because when you specify multiple email
they are usually separated by semi colons, and if you guys remember in this post I want to Assign Tasks to multiple people dynamically; and to do this I use my loops to deteremine who should get the tasks and build the list or task participants using . I use the following configuration:
The last thing I do in the loop is use a Task Process to Assign my tasks dynamically to the email addresses i've determined in the previous step. The action is configured as follows:
I set the Assign options as follows:
As you guys can remember in my previous post the workflow action is aimed towards Assigning a task to a group of Users, and allows workflow designers to specify task assignment criteria ( or in ) as well as completion criteria ( or ).
This functionality allows us to control how we would like to Assign the tasks to Approver and the Deputy as required, i.e.
- In series (one after the other); this option works really well if Assign Tasks to users in a SharePoint Group, this has been discussed in this post here,
- In parallel (all at once)
The advantage of this is that it will allow you to be dynamic . So if you have a complex process that requires you to cater for both scenarios without having to make changes to the workflow this can be utilised really well.
Also now that we have the schedule workflow feature available on office 365, Brad Orluk has a good blog post on this new feature titled: Tee Up Your Work - Scheduled Workflows Are Available for Office 365! ; be sure to check it out
In any case i'll probably cover this in a follow up post to show you guys how you can use this to your advantage.
I hope this helps someone out there
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.