based on the roles want to set the field editable

chinna
Mega Guru

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

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@chinna 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@chinna 

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

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@chinna 

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

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader