Add a single user to multiple assignment group

DeveloperG
Tera Contributor
I need to design a flow in ServiceNow that allows adding a user to multiple assignment groups selected in a request. Each selected group should require approval from the requestor’s manager. The approvals must be handled independently for each group. If the manager rejects the request for any specific group, the user should not be added to that group; however, for all other groups where approval is granted, the user should be successfully added.
8 REPLIES 8

Tanushree Maiti
Tera Patron

Hi @DeveloperG 

 

Try these steps:

 

Step 1: Catalog build.

Ensure you have following 2 variables in catalog form:

  1. User Variable: A Reference variable pointing to the sys_user table (like requested_for).
  2. Groups Variable: A List Collector variable pointing to the sys_user_group table. 

 

Step 2: Flow Designer Setup

Follow this logic flow :

  • Trigger: Set to Service Catalog on the sc_req_item table.
  • Get Catalog Variables: Add an action to pull your User and Groups variables.
  • For Each Loop: Use the For Each flow logic. Pass your list collector "Groups" variable array into this loop to process each selected group individually. 

Inside the For Each loop, perform the following actions:

  1. Look Up Group Record: Use the Look Up Record action to find the group in the sys_user_group table using the Current Item from your loop. 
  2. Add an Ask for Approval action
  3. Set the Approver to the Requestor's Manager
  4. Approval Check (If Block): Create an If condition to verify if the approval state is Approved
  5. Add an If condition directly after the approval step checking if the approval state is Approved.
  • If approved, use the Create Record action to add a new record to the sys_user_grmember table 
  • Map the User field to the requested user and the group field to the current group being processed in the loop

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

DeveloperG
Tera Contributor

@GlideFather Can you please help

 

DeveloperG
Tera Contributor

DeveloperG_0-1779903798885.png

@GlideFather  Please see this

@DeveloperG here your screenshot says inactive but it's not that as it wouldn't work at all and you said it worked partially..

 

perhaps the condition on step 11 - instead of if else to make it just if or anything else.

 

Perhaps it would be helpful to see the executions, click the test button select for existing RITM (no need to create new data) then run the test, see the flow execution with details, then you can update your flow and test it the same again with the same record until you achieve what you want to achieve.

 

My example is with knowledge approval but for demo purposes it shall be ok:

GlideFather_0-1779917262616.png

 

Flow execution - conditions evaluation (if you approve it manually then you can refresh this to see the latest change)

GlideFather_1-1779917269793.png

 

_____
Answers generated by GlideFather. Check for accuracy.