Vadim Tabakman

Jump to bottom

Nintex Workflow - Calculate Half the Size of a Collection UDA

Calculating the size of a Nintex Workflow collection variable is not hard to do.  There is a Collection Operation action and it can be configured to do a Count on a collection variable and store the result in a Number variable.  To get half of that number is also quite simple, in that there is a Math operation action that can divide that number by two.  Sometimes though, the number of values in a collection is an odd number, and as a result of dividing it by two, you get a non whole number.  eg. if the collection had 5 values, half of that is 2.5.

In this scenario, what have is a collection of approvers.  What we need, is at least half of them are require to approve a task. 

The Request Approval action has an Approval option named "Vote".  This is where you specify how many people need to vote for approval.  It is basically a minimum approval count required.

User Defined Action

The above description of a calculation is fairly basic. In order to get a whole number, we need a few more actions. 

  1. Collection Operation - this gets the total count of values in a Collection Variable
  2. Math Operation - divide the count by 2 (two)
  3. Build String - to use the Inline function fn-Round (this will round up/down the number)
  4. 4. Convert Value action - to convert the text string from Step 3 to a number variable.

Again, all this is quite basic.  Why put it into a UDA? Well, it's 4 actions I won't have rebuild if I need to do this later.

UDA Design

The reason I want to stress that all these steps are easy, is that creating this UDA was about making something reusable, something that is easily shared and demoed.

To use this UDA, you simply pass in a Collection variable as input and a Number variable as output. 

UDA Configuration

Once you have run this UDA, if your UDA has 5 values in it, you will get the number 2 back.  You can then use this Number variable in a Request Approval action to get 2 approvals back from a total of 5 approvers... or 3 approvals back from 6 approvers etc.

Request Approval

Downloads 

Nintex Workflow 2013

Download the User Defined Action (NWF) - Download and Import into the User Defined Action Designer

Download the User Defined Action (UDA) - Download and Import into the Manage User Defined Action

Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

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





 

Statistics

  • Entries (236)
  • Comments (1721)

Categories