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.

Make Variable Editor Readonly only for few variables.

Shubham_90
Tera Contributor

I have a Record producer, in that i created some fields in it. To show all fields on my custom tables i have created a Variable editor.  Now i can see all the fields on my table. and to make all the fields Readonly i have used below code. But it's making all the fields Readonly, I want some of the fields editable. How can i achieve this? 

Can anyone help me on this please ?? 

 

function onLoad() {
   g_form.setVariablesReadOnly(true);
}
2 REPLIES 2

Collin Romeijn
Mega Guru

Hi @Shubham_90 ,

Why are you using a variable editor and not making fields per question from the form into the custom record as intended ? That way you can use ACL's/UI Policy/views to make field read only and have a beter control over them.

If this is your only way try the code: g_form.setReadOnly(variableName, true);

See these articles for more assistance:
GlideForm - Client
setVariablesReadOnly method is not working on Variable Editor on Incident table - Support and Troubl...

Kind Regards,
Collin

Ankur Bawiskar
Tera Patron
Tera Patron

@Shubham_90 

simply make the other variables editable explicitly after that line

function onLoad() {
    g_form.setVariablesReadOnly(true);
    g_form.setReadonly('variable1', false);
    g_form.setReadonly('variable2', false);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader