flow designer for each loop, how to add logic to close Request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2021 07:01 AM
Hello,
I have a for each loop to add users to AD group, and that works fine.
However, I need to add logic to the flow, so the request is closed if users are added to ad group successfully.
It does not have to be all the users from list collector, but as long as some are added I want the request to be closed complete.
Now if i add the if logic to check if status was success within the for each loop then it will change the state of the request for each user it adds?
see my flow below, where I have moved the if step and update record step out of the for each loop...
, but here also it does not work. as the runtime value does not equate to success, but equates to {0}??? im not sure why this is, maybe because I am checking outside the for each loop?
ccan someone provide a suitable solution here please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 04:38 AM
ServiceNow released the scratchpad equivalent for Flow Designer with Quebec, now called Flow Variables. Explore on that part
What’s new with Flow Designer in Quebec
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2021 02:33 AM
however, the flow variable is a string type and in the for each loop, in each iteration the value just gets updated and the last iteration of the for each loop becomes the latest value.
I need a way for the flow variable to be integer and go up a number each time the for each is success.
and then I can do some logic outside of flow which checks that if count > 0 then close complete the flow, else incomplete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2021 03:08 AM
Hi,
can you try this
1) use custom script action and increment the count by 1 everytime for that global variable
at the end outside just check the count using custom script action and update record accordingly
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 06:37 AM
@Ankur Bawiskar - I'm stuck at a similiar situation. In a for loop, I'm adding user to Okta group. So inside each iteration, I have an if and else. If action succeeds, update RITM record that user is added to specific group, else if the action fails, create a catalog task as a error handling mechanism. Now if we are successfully able to add user to all the Okta groups, I want to mark the RITM completed. I'm not sure how I will find that out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 06:40 AM
I suggest to post a new question with all the details screenshots etc and tag me there as this is an old thread.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader