How to Make Variables Read Only Using g_form in ServiceNow

Variables Read Only

I was recently working with a colleague who mentioned that he had seen a new (un-documented) g_form method which allows you to set all catalog item Variables to Read Only. As you can probably imagine, this is great news for all ServiceNow developers who in the past had to resort to DOM manipulation, custom Business Rules or lots of UI Policies (thanks to my mentor Mark Stanger for providing information on these options in the past) just perform this trick (makes it so fulfillers of tasks update variables but they can’t be updated from the catalog item request). Without further waiting; here’s the magic:

g_form.setVariablesReadOnly(true);