how to add user to groups via catalog workflow?

Laxmi23
Tera Contributor

I have a requirement where i need to add the user to a groups via workflow. The field in the catalog item Groups(sys_user_group) is of type (list collector).another
The field in the catalog item user(sys_user) is type reference.when i select 2 groups and one user then each group manager approve request then only the user will add the group

Is it possible to add the user to the groups via workflow? If yes, Please help me with the script.

Thanks,

1 ACCEPTED SOLUTION

DirkRedeker
Mega Sage

Hi

You need to use an 'Approval - Group' Workflow Activity for the groups to approve.

Inside that 'Approval - Group' Activity you need to select, that the Approval is only valid, when all groups approved.

To send the approval to your desired groups, add the sys_id in the answer array of the script inside the Approval - Group activity.

Let me know if that answered your question and mark my answer as correct and helpful, please.

BR Dirk

View solution in original post

7 REPLIES 7

Elijah Aromola
Mega Sage

The following code should work for you. Replace the placeholder spots.

var groupQuery = new GlideRecord('sys_user_grmember')
groupQuery.initialize()
groupQuery.user = current.user //whatever your current user field is
groupQuery.group = "group_sys_id"
groupQuery.insert();

Please mark this as helpful/correct if this resolved your question!

Hi  Elijah Aromola its working but user goes to add in group without group manager approval.how to set group manager approval then only user add in the group.

thanks

 

 

Hi Chiru,

you need to use group approval workflow activity for this and select the group to which it must be sent for approval;

after the approval activity if it is approved use the above script in run script activity

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

DirkRedeker
Mega Sage

Hi

You need to use an 'Approval - Group' Workflow Activity for the groups to approve.

Inside that 'Approval - Group' Activity you need to select, that the Approval is only valid, when all groups approved.

To send the approval to your desired groups, add the sys_id in the answer array of the script inside the Approval - Group activity.

Let me know if that answered your question and mark my answer as correct and helpful, please.

BR Dirk