String array in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 02:51 AM
Hi ,
I am working flow designer , i have declared one string type flow variable. it has values separated by comma.
like var v= 'str,pqr,atf';
i want to runfor loop to iterate this values. Anybody can help here ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 04:01 AM
Hi, you can create an action to convert that string to array. i am attaching an referral screen shot i have done
I have passed that flow variable as input to action to convert it into array and return that as an array and then i can user foreach to loop that array
The input of that action will be a string and output of that action will be an array.
You can try. if you have issue you can reply.
If it helps mark this as helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 10:09 AM - edited 11-15-2024 10:11 AM
Hi @arjun0101 ,
You need to create another flow variable (for example, 'variable test') and use 'Set Flow Variables' flow logic to set the value of the string flow variable with 'Split' transform function in it (1st SS shown below). Now your 'variable test' flow variable should have the array.
Once you have the array you can use the 'For each item in' flow logic to run a loop using the array flow variable ('variable test' variable in my example) in items field. (2nd SS shown below).
If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 05:16 AM
Hi @arjun0101 ,
If you got chance to check the solution and if it worked,
Please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 06:03 AM
Hi arjun0101 ,
You can use the .split() method to separate the string and convert it into an array, making it easier to apply a loop with the array.Try with following code.
// Example string variable
var v = 'str,pqr,atf';
// Split the string into an array using the comma as a delimiter
var valuesArray = v.split(',');
// Iterate over the array using a for loop
for (var i = 0; i < valuesArray.length; i++) {
// Access each value using the index
var value = valuesArray[i];
// Do something with the value (e.g., log it)
gs.info('Value: ' + value);
}
Thank You...!