Adding a user to the watchlist automatically

kali
Tera Contributor

Hi All,

Whenever a hr case is created and assigned to a particular assignment group , a user needs to be added in the watchlist automatically . Thanks in advance

2 REPLIES 2

Mohan raj
Mega Sage

Hi @kali,

 

You use Before Business rule on insert and try below script 

 

(function executeRule(current, previous /*null when async*/ ) {

var arr = []; 

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group' ,current.getValue("assignment_group"));
gr.query();
while (gr.next()) {
    arr.push(gr.getValue("sys_id"));  //store sys_id of user's 
}

current.u_assignment_group = arr;
gs.log('test u_assignment_group ' + current.u_assignment_group);
})(current, previous);

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

I would add to this, that you could think of creating an "HR Case Option" to trigger this functionality not for all HR Cases. You might not want to have it always executed.