Using Display Business Rule: If User is Service Desk group then only populate Manager field on incident form

Shawn33
Tera Expert

If the User is belongs to Service Desk group member then only populate Manager field on incident form , need to achieve this by using Display BR

1 ACCEPTED SOLUTION

Raghu Ram Y
Kilo Sage

HI @Shawn ,

Try below...Working...Tested..

Create Display Business rule and use the below code..

(function executeRule(current, previous /*null when async*/) {
 g_scratchpad.checkuser = gs.getUser().isMemberOf(gs.getProperty('checkUserInGroup'));
})(current, previous);

Note: As part of best practice, I have used "System Property" instead of passing group name directly here..

 

To create system Property do like below screenshot.

1. In Navigator type "sys_properties.LIST" and create a new one as below.

find_real_file.png

In Value pass the group SysId and in type select as "String"

 

Then Create Client script and use the below code.

 if (g_scratchpad.checkuser == true) {
        g_form.setValue('u_manager_new', g_user.userID);
    }

I hope it definitely helps you, if so please mark my response as correct and helpful

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

populate manager field with what?

which user? logged in user?

Regards
Ankur

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

Hi Ankur,
Thanks for responding.


I think with logged in user , if we select random user in incident caller id field belongs to service desk group , in this case we can't use Display BR i think so,

So pls help me with possibility way with using Display BR case.

Hi,

Display BR would run only once when form loads

If you wish to do this check when caller is changed then you need to use onChange client script + GlideAjax

In script include check if caller is member of that group and return true or false

Regards
Ankur

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

Yes i got, but i need to do this using Display BR,

may be we can write for logged in user ,
when form loads then logged in user caller_id should be populate for Service Desk group members only.