g_form.setVariablesReadOnly(false) not working for all variables in VEditor

Raphael Dizon
Mega Expert

Hello,

I have tried creating a client script in ritm table so that variables in VEditor won't be read only, I used g_form.setVariablesReadOnly(false); and it only made some fields editable but not all, why is that?

find_real_file.png

13 REPLIES 13

Hi,

Usually you need to have catalog client script so that the script runs only for particular catalog item and not for all catalog items

1) Applies to -> catalog item

2) type -> onLoad

3) Catalog item -> your catalog item

in script add that code

function onLoad(){

g_form.setVariablesReadOnly(false); 

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi,

I have tried this, and it's not working because we have a client script in the RITM table that sets all the variables in veditor to read-only. That's why I am trying to create another client script in the RITM table to make some fields editable however, it's not working on some variables

Sagar Pagar
Tera Patron

Hello,

 

The order of onLoad catalog client script should be greater than all other catalog client script and catalog UI policies.

 

Regards,

Sagar Pagar

The world works with ServiceNow

Hi Sagar,

I tried setting the order to the highest and still some fields are not editable in the veditor

Swapnil Soni1
Giga Guru

Hi Raphael Dizon,

You can use this-

For fields on the form use g_form.setReadOnly('<fieldName>', true);

For catalog variables use g_form.setReadOnly('variables.<variableName>', true);

Or you can go through it -

https://hi.service-now.com/kb_view.do?sysparm_article=KB0752560

 

If this solves your problem please mark helpful or correct.

Thanks

Swapnil Soni