How to add user to group (sys_user_group) using Flow designer

Kifrez
Kilo Guru

Hi, could you please let me know if you have used/added user from sys_user table to group (sys_user_group) using Flow Designer?

If so, how do you do it? What action do you use ? I can't seem to find the action

Or does anyone know how to automate adding user to a group within ServiceNow?

1 ACCEPTED SOLUTION

sk8
Kilo Expert

Hi Freddy,

To add the user to a group in Flow designer follow the below steps:

1. Add create or update record action.

2. Select Table name - Group member [sys_user_grmember].

3. Now select the group field and select the group in which you want to add a user.

4. Select the user field and select the user to add to the group.

 

Please mark answer as helpful/correct if it works for you.

Regards

Sk

View solution in original post

15 REPLIES 15

To change the display value of a table go into the table it self and select "Display" as true on the field (in this case Name) you want to be shown when that table is referenced in reference fields.

So go in the Table of tables, find the sys_user_group table. Open that record, then find the name row and then in the display column change it to true.

This worked. thanks so much.

Simple and perfect, thanks.

harun_isakovic
Mega Guru

Hi Freddy, 

Here is a sample script to add a user to a group, which you can just copy/paste into the Script step in the flow designer.

var gr = new GlideRecord("sys_user_grmember");
gr.initialize();
gr.setValue("user", "put sys_id of user here");
gr.setValue("group", "put sys_id of group here");
gr.insert();

Here is a link explaining the Script step

https://docs.servicenow.com/bundle/paris-servicenow-platform/page/administer/flow-designer/reference/javascript-step-action-designer.html

 

Hi @harun.isakovic , Thanks for the script. It will help me for other thing.

However, I would need the user and group sys_id to be dynamic which obtained from user input.

find_real_file.png