The CreatorCon Call for Content is officially open! Get started here.

How to auto populate users to group dynamically ?

Community Alums
Not applicable

Hello,

How to add new users to in a particular group, when a table is updated with new user.

ex: table : custome table
     Group : Service Incident Group

I know for this i have to write business rule, here i'm looking for script.

Thanks and Regards,

1 ACCEPTED SOLUTION

Manoj Kumar16
Giga Guru

write an 'after' 'insert' and 'update' business rule in the custom table-

var gr=new GlideRecord('sys_user_grmember');

gr.initialize();

gr.group="Sys_ID of Service Incident Group";// best practice is to get the sysID using a property

gr.user=current.FIELD_NAME_WHICH_CONTAINS_THE_NEW_USER_IN_CUSTOM_TABLE;

gr.insert();

View solution in original post

6 REPLIES 6

Good eye Jim, I did have to add the below to make it work right.

gr.addQuery('group',"sys_id_of_group");

rajneeshbaranwa
Giga Guru

You can use below,

 

create an after business rule


var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.group = '{{group_sys_id}}';
gr.user = current.user;   //use field name containing user in customer table
gr.insert();