A question about OnCellEdit client script and a role-based condition

mitzaka
Mega Guru

Hi SNC,

I want to restrict all users but the ones having a certain role from being able to edit the 'state' field in incidents, when double-clicking in the list views.

Could I use an OnCellEdit script and have the role condition in there? Has anyone tried that?

Thanks!

1 ACCEPTED SOLUTION

Hi Dimitar,



Thanks for the update. You have to create a ACL of operation type "list_edit" and then restrict based on roles.


http://wiki.servicenow.com/index.php?title=Using_Access_Control_Rules#gsc.tab=0


View solution in original post

8 REPLIES 8

Hi,



So you mean for other roles also it is giving that message?


You can turn on debugger to investigate it further.


I get the same message for every role other than ADMIN. And the debugger clearly says that I don't pass the list_edit ACL.


list_edit.png



My script in the ACL is the following:



if (g_user.hasRole('problem_management')) {


g_form.setReadonly('state', false);


}


else g_form.setReadonly('state',true);


Hi DImitar,



You have to write server side script and set return false or true.


OK, got that.


Another approach I found was to just create a simple List Option UI Action, have it be applied only to users with certain roles and have the script in it do what I want to do.



Thanks for the answers!