flow designer for each loop, how to add logic to close Request?

Khalnayak
Tera Guru

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...

find_real_file.png

, 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? 

 

find_real_file.png

 

ccan someone provide a suitable solution here please?

14 REPLIES 14

@Khalnayak 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar so i used glow variables and have managed to get the for each loop  output stored in variable and access outside it.

find_real_file.png

 

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.

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Harini17
Tera Expert

@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.

@Harini17 

I suggest to post a new question with all the details screenshots etc and tag me there as this is an old thread.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader