- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 08:37 AM
Hi,
Can you help me to make below particular variable read only when state is closed complete or closed incomplete or closed skipped. (screenshot attached)
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2022 04:55 AM
Hi
This can be done using a Client Script on Catalog Task Table. You just need to write an On Change Client Script on Catalog Task Table on State Field and use the script below:
This client script will take care of both scenario when state changes also after you save the form it will validate for the state value to make it read only.
Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
var getState = g_form.getValue('state');
if (getState == 3 || getState == 4 || getState == 7) {
g_form.setReadOnly('variables.checkbox', true);
}
return;
}
if (newValue == 3 || newValue == 4 || newValue == 7) {
g_form.setReadOnly('variables.checkbox', true);
}
//Type appropriate comment here, and begin script below
}
Screenshot for reference:
Result:
Script is an tested one in my PDI and will work for you as well for the query mentioned.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 08:42 AM
Configure a Catalog UI policy based on your condition.
https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/product/service-catalog-management/concept/c_ServiceCatalogUIPolicy.html#:~:text=UI%20policies%20can%20be%20used,applied%20to%20service%20catalog%20items.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 08:45 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 08:55 AM
Do you want to do at requested item level or catalog task level?
In either scenario, you can always configure catalog client script and use g_form.setReadOnly(field, boolean) method make field read only based on state
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 09:12 AM
I wrote below code:
function onSubmit() {
var statevalue = g_form.getValue('state');
if((statevalue == 7) || (statevalue == 4) || (statevalue == 3))
{
g_form.setReadOnly('Additional_software_requirements', true);
}
}
But after saving the form, the variables gets editable again.
Any suggestions ?