When RITM is read-only, how to allow a role or group to edit?

yvonnew
Kilo Guru

We have a Business Rule which locks down all RITMs so that the variables cannot be edited. We now have a requirement for a certain role to be able to unlock variables on a particular catalog item. Is anyone able to point me in the direction of a solution please?

The Business Rule runs on the sc_item_options table

When to run:

Before Update

Updated by is not system

Condition:

current.value.changes()&&current.value != previous.value

Script:

gs.addInfoMessage('You are not allowed to change any information on this form once submitted.');

current.setAbortAction(true);

abort_on_variable_change.JPG

1 ACCEPTED SOLUTION

ark6
Mega Guru

Not the right way though to disable variables.



However, with your current design you can do this.



if(!gs.hasRole('custom_role')//custom_role this is the role which will have access to variables


{


gs.addErrorMessage('You are not allowed');


current.setAbortAction(true);


}



However, have a look at the below for disabling vaiables



Check below for different ways to disable a variable, I personally like the client script one.



https://www.servicenowguru.com/scripting/business-rules-scripting/variables-form-readonly/


View solution in original post

6 REPLIES 6

ark6
Mega Guru

Not the right way though to disable variables.



However, with your current design you can do this.



if(!gs.hasRole('custom_role')//custom_role this is the role which will have access to variables


{


gs.addErrorMessage('You are not allowed');


current.setAbortAction(true);


}



However, have a look at the below for disabling vaiables



Check below for different ways to disable a variable, I personally like the client script one.



https://www.servicenowguru.com/scripting/business-rules-scripting/variables-form-readonly/


Vignesh21
Kilo Guru

Hi,


You can try creating onload client script on catalog item :



function onLoad() {



if(g_user.hasRoleFromList("xyz") ){



g_form.setReadOnly('requested _for', false);



}