based on the roles want to set the field editable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2020 05:02 AM
Hi team,
based on the itil and incident_manager role i want to make field editable on incident form.
for example, if user selects the field status = false and qualified = false in the incident form, want to give the permission to edit the field category in incident form who has contain itil and incident_manager role. even admin also not able to edit that field without those roles.
can anyone help me with the acl script.
Regards,
chinna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2020 05:08 AM
Hi,
there are couple of approaches
ACL approach recommended
1) create field level WRITE ACL on Category field
2) admin overrides as uncheck
3) condition as Status=false and qualifier=false
4) script below
answer = getValue();
function getValue(){
var itil = hasRoleExactly('itil');
var incidentManager = hasRoleExactly('incident_manager');
if(itil || incidentManager){
return true;
}
else{
return false;
}
}
function hasRoleExactly(role) {
var au = new global.ArrayUtil();
var roles = gs.getSession().getRoles() + '';
var roleArray = roles.split(",");
var isAuthorized = au.contains(roleArray, role);
return isAuthorized;
}
}
Another approach onChange client script on both the fields status and qualifier
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(g_user.hasRoleExactly('itil') || g_user.hasRoleExactly('incident_manager')){
if(g_form.getValue('status') == false && g_form.getValue('qualifier') == false){
// make field editable
}
else{
// make field readonly
}
}
}
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
12-31-2020 05:33 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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
01-03-2021 07:51 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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-15-2021 05:07 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader