Make assignment group and assigned to fields editable only to admin and incident manager. For others these fields should be readonly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 06:25 AM
Make assignment group and assigned to fields editable only to admin and incident manager. For others these fields should be readonly.
How can I do this from client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 06:32 AM
You need to use Access Control lists to achieve this please create ACL's with conditions on respective table where you want to make those fields read only for other users and the other approach is client script below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(g_user.hasRoleExactly('admin') || g_user.hasRoleExactly('incident_manager')){
if(g_form.getValue('assignment_group') == false && g_form.getValue('assigned_to') == false){
// field editable
}
else{
// field readonly
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 06:37 AM
Hi Shraddha
This can be achieved Using client scripts,and ACL's.
Client script: You can write onLoad client script, check if user has particular roles and set readonly to true.
function onLoad(){
if(g_user.hasRoles('itil','incident_manager')){
g_form.setReadOnly('field1', true);
g_form.setReadOnly('field2', true);
}
}
ACL's - you need 2 write ACL's so that anywhere they are trying to edit those fields, the acl's will restrict the write access.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 05:02 AM