- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 04:48 AM
Hello,
I want when to change variable from mandatory to not mandatory when state of the catalog task changes to "pending".
is there any way to change the variables that came from catalog item ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 04:55 AM
you can use normal onChange client script on sc_task and use this script
Don't use catalog client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue.toString() == '-5'){
g_form.setMandatory('variables.variableName', true);
}
else{
g_form.setMandatory('variables.variableName', false);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 04:55 AM
you can use normal onChange client script on sc_task and use this script
Don't use catalog client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue.toString() == '-5'){
g_form.setMandatory('variables.variableName', true);
}
else{
g_form.setMandatory('variables.variableName', false);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 06:36 AM
thanks !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 04:55 AM
You can write a UI policy for that and provide coditions i.e state changes to pending Then apply the UI policy action as per your need.
please mark it as helpful and accept it as solution if it is helpful for you.
Regards,
Satyapriya