when assignment group is not empty assign to should be first member of assignment group

Mani Polisetty2
Tera Contributor

Hi ServiceNow folks,

 

I need some help on following query, Can you please help me on it. 

Query : when assignment group is not empty assign to should be first member of assignment group on incident record.

 

Thanks

Mani Polisetty

1 ACCEPTED SOLUTION

BharathChintala
Mega Sage

@Mani Polisetty2 

what do you mean first member of group?

 like added first to group or Alphabet wise first member?

 

write befor BR on Incident table

on insert and update

conditions

assignment groups changes and assigned to is empty

 

in advanced

 

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

    var gr = new GlideRecord("sys_user_grmember");
    gr.addQuery("group", current.assignment_group);
    gr.orderBy('sys_created_on'); // use this line if you want first added person to group
    gr.orderBy('user'); //user this if you want by alphabet
    // if you want random don't add orderby
    gr.query();
    if (gr.next()) {
        current.assigned_to = gr.user;
    }


})(current, previous);

 

BharathChintala_0-1678350001818.pngBharathChintala_1-1678350276062.png

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

1 REPLY 1

BharathChintala
Mega Sage

@Mani Polisetty2 

what do you mean first member of group?

 like added first to group or Alphabet wise first member?

 

write befor BR on Incident table

on insert and update

conditions

assignment groups changes and assigned to is empty

 

in advanced

 

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

    var gr = new GlideRecord("sys_user_grmember");
    gr.addQuery("group", current.assignment_group);
    gr.orderBy('sys_created_on'); // use this line if you want first added person to group
    gr.orderBy('user'); //user this if you want by alphabet
    // if you want random don't add orderby
    gr.query();
    if (gr.next()) {
        current.assigned_to = gr.user;
    }


})(current, previous);

 

BharathChintala_0-1678350001818.pngBharathChintala_1-1678350276062.png

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala