to make script field read only on user criteria form

hifza
Tera Contributor

requirement : a user having knowledge manager and knowledge admin role can able to create user criteria but script field should be read only after advanced button is clicked on the user criteria form.

attempted solution:

i created one acl on the user criteria table ,write and create operation ,roles knowedge manager 

i created one ui policy to make the script fied readonly

in ui policy: 

table : user criteria

run script,executed if true:

g_user.hasrole('knowedge manger)
ui policy action : script field readonly true

but i cannot make script field readoly other actions like setmandatory or setvisible is working but set readonly is not working.

2 REPLIES 2

Avinash_kurri1
ServiceNow Employee
ServiceNow Employee

Did you got fix for this issue, could you please share the fix details 

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @hifza and @Avinash_kurri1 ,

 

Simply create a onchange client script which sets the script field readonly onclick of Advance checkbox and if needed use g_form.hasroleExcactly to check for user role.

 

i hope this helps.... 

 

Sample code :

if(newValue == 'true' && g_form.hasroleExactly('knowledge_manager')){
g_form.setreadOnly('script', true);
} else{
// if any
}

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect