Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Lock down change states for users with change_management role

ebaileyybs
Tera Expert

Hi,

I am looking to lock down certain states available for selection within the change state field. Please see below options;

find_real_file.png

I would like for 'ITIL' users to only be able to select the following states;

Draft

Review

Closed

Users with the change_management role should be able to select any of the above states.

Any help with this would be greatly appreciate.d

Kind regards,

Emma

35 REPLIES 35

if(g_user.hasRole('itil') && !(g_user.hasRole('change_management')) && g_form.getValue('type')== 'Norma')


{//add all states that you want to remove


g_form.removeOption('state','approved')


g_form.removeOption('state','schedules')


//Others


}


if(g_form.getValue('type')=='normal')   //adding condition for type


{


if(g_user.hasRole('itil') && !(g_user.hasRole('change_management')))


{//add all states that you want to remove


g_form.removeOption('state','approved')


g_form.removeOption('state','schedules')


//Others


}


}


-Anurag

Thank you, this is now only applicable for Normal changes, however, the script does not run until the form is saved. Is there a way to avoid this issue?



Below is an example from an ITIL user before save;



find_real_file.png


Write the script at the time of onload clientscript


Hi Emma,



For any client side script change (client scripts / ui policies/ Ui Actions) , changes will be reflected only after the form is loaded, you dont necessarily have to save the record, just reload the window and you will see the changes.


-Anurag