business rules ITSM

HarithaP
Tera Contributor

There is a requirement that in incident form whenever we are changing the assignment group if any member is available in that group, set work notes that Group member available and if no group member found then set worknotes No group member available.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@HarithaP 

what did you start with and where are you stuck?

you can use GlideAjax for this

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

Amit Pandey
Kilo Sage

Hi @HarithaP 

 

You can do this with the help of Before Insert/Update Business rule. Set condition to Assignment Group is not empty and Assignment Group changes Here's the outline of the script-

 

var assignGroup = current.assignment_group.toString();
    var memGr = new GlideRecord('sys_user_grmember');
    memGr.addQuery('group', assignGroup);
    memGr.query();
    if (memGr.hasNext()) {
        current.work_notes = "Group member available";
    } else {
        current.work_notes = "No group member available";
    }

 

Please mark my answer helpful and correct.

 

Regards,

Amit

 

Community Alums
Not applicable

Hi @HarithaP ,

I tried your problem in my PDI and it works for me please refer below code 

var gr1 = new GlideRecord('sys_user_grmember');
gr1.addQuery('group', '8a4dde73c6112278017a6a4baf547aa7');
gr1.query();
while (gr1.next()) {
    gs.print("USER = " + gr1.user.getDisplayValue());
}
var getUserActiveGR = new GlideRecord('sys_user');
getUserActiveGR.addQuery('sys_id', gr1.user);
getUserActiveGR.addActiveQuery();
getUserActiveGR.query();
if (getUserActiveGR.next()) {
    gs.print("getUserActiveGR = " + getUserActiveGR.sys_id);
     current.work_notes = 'User is available = ' + getUserActiveGR.first_name + getUserActiveGR.last_name;
}

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak