Skip to main content
Nintex Community Menu Bar
Answer

compare collection variable to a variable

  • April 10, 2020
  • 4 replies
  • 91 views

Forum|alt.badge.img+4

I have a collection with values Item_Coll ["US100000","US100000","US100000","US100000000","US2000000","US2000000","US30000000","US50000000"]

I have another variable having B= US150000

I want to get the first value that is greater than variable B within this collection.

How can I get that in office 365 Nintex workflow?

 

 

Best answer by SimonMuntz

I would use a regular expression action or an Extract Substring from Index of String action to trim the US from the start of the number first.

If you use a workflow variable that is of type integer then comparisons available in actions will change from string operations such as contains to comparisons such as greater than.
Use a Run if action for example to do the comparison. If its run then record which value is greater and meet the condition that stops processing the for each action.

4 replies

SimonMuntz
Nintex Employee
Forum|alt.badge.img+23
  • Nintex Employee
  • April 14, 2020
Hi,

Put your collection through a for each action that pulls each index out one at a time and compares it to B. If it is greater add it to a another collection variable. You will be left with a collection variable that has all the values greater than B but extracting index 0 will give you the first.

You could add more logic that stops processing of the for each once the first value that is larger is found negating the need for the second collection variable.

Forum|alt.badge.img+4
  • Author
  • April 14, 2020
Simon, this is how it should work as per c# or any other programming language.
In Nintex for Office 365 For comparing greater than what should be used. I even tried creating a new collection of numbers but when it comes to comparing greater than some value I do not see any action. This might be trivial. Can you assist

SimonMuntz
Nintex Employee
Forum|alt.badge.img+23
  • Nintex Employee
  • Answer
  • April 15, 2020
I would use a regular expression action or an Extract Substring from Index of String action to trim the US from the start of the number first.

If you use a workflow variable that is of type integer then comparisons available in actions will change from string operations such as contains to comparisons such as greater than.
Use a Run if action for example to do the comparison. If its run then record which value is greater and meet the condition that stops processing the for each action.

Forum|alt.badge.img+4
  • Author
  • April 22, 2020

Thanks SimonMuntz, I was comparing a number with string. Later I converted the collection to Numeric and then checked for the condition.