cancel
Showing results for 
Search instead for 
Did you mean: 

Share a Collection Variable between workflows

Workflow Hero
2 0 914

These steps provide an alternate method to share a Collection variable across multiple workflows, should the Store/Retrieve method not suit. In this example I have 2 list workflows where Workflow1 creates the Collection variable and Workflow2 continues to use the Collection variable.

STEP 1: In Workflow1 use an Update Item action to copy the Collection variable called varCOLString to a Multi-Line Text column called tString.

1.PNG

Example: Based on our collection variable the text in our tString column might look like this: 1;2;3;4;5;6;7;8;9;

STEP 2: In Workflow2 use a Set Variable action to copy the tString column to a Multi-Line Text variable called varMLTString.

2.PNG

STEP 3: Use a Build String action to count the number of characters in varMLTString and store this in a Text variable called varTXTLastChar.

3.PNG

Text: fn-Length({WorkflowVariable:varMLTString})

Example: Based on the string 1;2;3;4;5;6;7;8;9; the result in varTXTLastChar will be 18.

STEP 4: Use a Math Operation action to subtract 1 from varTXTLastChar and store this in a Number variable called varNUMCount.

4.PNG

Example: Now the value we carry into varNUMCount is 17.

STEP 5: Use another Build String action to remove the last character from the varMLTString variable using the Remove inline function and varNUMCount as a reference.

5.PNG

Text: fn-Remove({WorkflowVariable:varMLTString}, {WorkflowVariable:varNUMCount}, 1)

Example: We've removed one from the character count because the Remove inline function starts at zero. The varMLTString variable now looks like this 1;2;3;4;5;6;7;8;9 (we have removed the trailing ";").

STEP 6: Finally use a Regular Expression action and the Split function to output the values of varMLTString into a new Collection variable called varCOLString.

6.PNG

Example: The string 1;2;3;4;5;6;7;8;9 will be split by the ";" character and each value will be added to the new collection.