- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 01:57 PM - edited 10-02-2023 02:48 PM
In Flow Designer, I have a For Each Item action that looks through a list of computers. In that section, I'm generating SCTASKS for each item, and I want to close the associated RITM and REQ only after each item has been processed. How could I determine the number of items in my For Each Item action so I could include an IF statement that says if my counter variable equals the number of items in the For Each Item action, then do a certain action?
I have a Set Flow Variables action at the beginning of my flow, and I'm using the following script to count the number of items in my asset_tags list variable.
var assets = fd_data.trigger.request_item.variables.asset_tags.length;
return assets;
My thought process here is that using the .length method would count the number of entries in the asset_tags variable, and that I could return that value for the Flow Variable, but there is no runtime value when I test my flow.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 03:45 PM
I've got the solution. All I had to do was move the subflow used to close the RITM & REQ on the same level as the For Each Item action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 03:13 PM
Hi @cwolfe01
If .length didn't work, you can try an alternate approach.
1. Create a flow variable called counter of type integer.
2. Before for each set the counter variable to 0 using flow logic -> Set flow variable
3. Now, inside for each increment the counter variable value by 1, to do this set flow variable value using inline script.
return fd_data.flow_var.counter + 1;
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 03:24 PM
How would I determine if my counter variable matches the number of iterations my loop has?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2023 03:45 PM
I've got the solution. All I had to do was move the subflow used to close the RITM & REQ on the same level as the For Each Item action