variables read only

jean-pauldehaas
Tera Guru

Hi all,

 

i have a catalog item with a lot of variables, one of the variables is a radio button.

the radio button has a No & Yes option and if users select No first then populate a few variables and decide they need to select Yes it should make all the variables on the form(populated or not) Read only.

 

i did this via a ui policy run script but it only works for variables that are already populated not the empty ones.

 

anyone has a good way to do this ?

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

If any variable is mandatory and you are trying to make it readonly then it will not work.

Along with readonly you have to make that variable non-mandatory first.

Use below script logic in your script:

 

g_form.setMandatory('variable_name',false);  // first make non-mandatory

g_form.setReadonly('variable_name',true);  // then make readonly

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

3 REPLIES 3

Anil Lande
Kilo Patron

Hi,

If any variable is mandatory and you are trying to make it readonly then it will not work.

Along with readonly you have to make that variable non-mandatory first.

Use below script logic in your script:

 

g_form.setMandatory('variable_name',false);  // first make non-mandatory

g_form.setReadonly('variable_name',true);  // then make readonly

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

thanks should have thought of that!

Vishal Birajdar
Giga Sage

Hello @jean-pauldehaas 

 

If possible can you please share your script please...!!!

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates