- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 11:23 PM
I have a requirement that if status is 'Completed' then only sysadmin can update status for such records
EG: if Incident status is Completed, only System admin can edit the status but it should be restricted for Incident manager role only when status is completed.
Where as Incident manager role has access to all the fields on the form via *acl.
I have tried this but its not working.
Admin Overrides is checked
Write operation
selected the required field 'Status'
if (current.u_status == 'Deleted') {
if ((gs.getUser().hasRole('x_critcinc_manager')) || (gs.getUser().hasRole('x_mim_manager'))) {
answer = false;
}
} else {
answer = true;
}
Please suggest. Is it possible to restrict the specific choice for a specific role ?
Appreciate the Help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 03:45 AM
you cannot control choices from ACL.
Better have field level WRITE ACL and then have Before update to check if choice value change is allowed
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 11:43 PM
you can restrict field using field level WRITE ACL but not choice
to handle choice value you can use before update BR and stop the update by checking the role etc
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
07-26-2023 12:02 AM - edited 07-26-2023 12:16 AM
Hello @SAS21 -
Well, I think you can achieve this using the client script as well. This is suitable when the requirement is to restrict the user on opening of the form. I would suggest not touching ACLs for such kind of requirements.
The client script would be something like this: (Type= onLoad)
if(g_form.getValue('status') == 'Completed'){
if(!g_user.hasRole('admin')){
g_form.setReadOnly('status', false);
}
}
If my answer helps, please mark it as correct.
Thanks,
Ni**bleep**a.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 12:34 AM - edited 07-26-2023 12:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 01:47 AM
your script is onLoad so it will work only once when form loads
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader