Solved

Parse collection variable and build a string

  • 21 July 2023
  • 1 reply
  • 205 views

Badge +1

At first this seemed to me like a basic parse, but somehow I couldn’t crack it, any help would be greatly appreciated. 

I have 3 collection variables. 

Quantity - 34; 45; 

Description - myRecord1; myRecord2; 

Price - 599;899;

I want to build a string like this using Nintex workflow.

Final Text / Desired Output - #34, myRecord1, $599 \n\r #45, myRecord2, $899

How do I achieve this using Nintex workflow? 

icon

Best answer by Garrett 21 July 2023, 21:00

View original

1 reply

Userlevel 6
Badge +16

Hi @CherryDev 

Does all the collection variables have the same count of items? Yes

Use Loop instead of for-each Loop.
Use Get Items from Collection and specify the Index.
Nintex uses 0-based Index. first item is at index 0. last item is at index n-1 (where n is the total items in the collection
Use Build String to build the string 

 

PSEUDOCODE

Count Items in collection (any one) → int_count
Set var → int_index equals 0
Loop int_count times
    Get item from collection (Quantity) at index int_index → txt_quantity
    Get item from collection (Description) at index int_index → txt_desc
    Get item from collection (Price) at index int_index → txt_price
    Build String → txt_string = txt_string + txt_quantity +  txt_desc + txt_price + “\n\r”
    //Append new row to the variable txt_string 
    Log to History → txt_string  //verify value
    Calc: int_index = int_index + 1  //Important! → increment the index by 1
Log to History → txt_string  //verify FINAL value

 

Hope this give you a rough idea  for the implementation

Reply