Assign to field values on visible if logged in user is member of the group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 05:42 AM
Hi,
Assign to field values only visible to logged in user is a member of the selected group.
Eg : I'm not a member of that group,then I select assign to field it needs show empty, otherwise if I'm member of the corresponding group then group members name needs to show
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 05:48 AM
why not show that field only to those group members?
Create field level READ ACL on Assigned to field and use script in advanced script
answer = gs.getUser().isMemberOf('groupName');
OR
You can use onLoad client script + Display BR for this and hide it
(function executeRule(current, previous /*null when async*/) {
// Get the group sys_id for group ABC
var groupSysId = 'YOUR_GROUP_SYS_ID'; // Replace with the actual sys_id of group ABC
g_scratchpad.showAssignedTo = gs.getUser().isMemberOf(groupSysId).toString();
})(current, previous);
function onLoad() {
// Check the scratchpad value set by the Display Business Rule
if (g_scratchpad.showAssignedTo === 'false') {
// Hide the Assigned To field if the user is not in group ABC
g_form.setDisplay('assigned_to', false);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:25 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 06:06 AM - edited 12-19-2024 06:08 AM
Hi @Arun_Manoj ,
Which table you have this assigned to field?
If you want to show assigned to field if user part of specific group then go with Ankur solution.
It’s business usecase or your doing in pdi. Best way to do is depends on assignment group show assigned to users part of that group.
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 06:33 AM - edited 12-19-2024 06:34 AM
Hello @Arun_Manoj ,
I have tried this in Incident table and its working fine and Thank you Ankur your scripts was giving result as expected.
First you can write a Display BR. in incident table:
(function executeRule(current, previous /*null when async*/) {
// its giving all groups dynamically to pass in scratch pad variable
g_scratchpad.showAssignedTo = gs.getUser().isMemberOf(current.assignment_group).toString();
})(current, previous);
Write the Onload Client script :
function onLoad() {
if (g_scratchpad.showAssignedTo === 'false') {
// Hide the Assigned To field if the user is not in XYZ group
g_form.setDisplay('assigned_to', false);
}
}
Output:
Current logged in USer is not part of Software group so hiding the Assigned to Feild.
user is part of hardware group so he is able to see
If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.
Thanks
Sanjay Bagri