- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 12:29 AM
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 ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 12:42 AM
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
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 12:42 AM
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
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 01:01 AM
thanks should have thought of that!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 12:51 AM
Hello @jean-pauldehaas
If possible can you please share your script please...!!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates