Make assignment group and assigned to fields editable only to admin and incident manager.

Vrushali6
Mega Contributor

Hi everyone,

I want to Make assignment group and assigned to fields editable only to admin and incident manager. For others these fields should be readonly

I have written onload client script 

function onLoad(){
if(!g_user.hasRoleExactly('admin') || !g_user.hasRoleExactly('incident_manager')){
g_form.setReadOnly('assignment_group', true);
g_form.setReadOnly('assigned_to', true);
}
}
but its not working , can anyone help me with this?

Thanks
4 REPLIES 4

Kieran Anson
Kilo Patron

Hi,

If this is for security purposes, an ACL should be used to prevent write access as a client script will only change the UI, but can be worked around.

palanikumar
Mega Sage

Since you are using ! operation you should use &&

 

function onLoad(){
if(!g_user.hasRoleExactly('admin') && !g_user.hasRoleExactly('incident_manager')){
g_form.setReadOnly('assignment_group', true);
g_form.setReadOnly('assigned_to', true);
}
}
Thank you,
Palani

Ujjawal Vishnoi
Mega Sage
Mega Sage

Better approach would be ACL to implement this.

You can create a write ACL and can provide the role incident manger in the role and check the admin override. 

If you do not have any other ACL then for same thing then it should work.

Hope it helps.

Can you please help me with this in detail