- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 10:02 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 10:39 PM
HI
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 10:41 PM
Hi,
you can use this
Display BR:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.isMember = gs.getUser().isMemberOf('Service Desk');
})(current, previous);
onLoad client script
function onLoad(){
if(g_scratchpad.isMember.toString() == 'true')
g_form.setValue('caller_id', g_user.userID);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 10:39 PM
HI
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2022 02:26 AM
Hello @Shawn,
Glad to know that you got the solution..
But here I too suggested the same solution and also as a first response but not sure my solution was missed to mark it as correct/Helpful.
No problem, but a suggestion passing "Group Name" is not a best practice to use beacuse at later point of time if there is some requirement to update the group name then your script will get fail, so it's a best practice to use system property.