- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 09:36 PM
Hi ,
I have one catalog item.In first field ,I am selecting application .I have 2 other fields purpose and RTO . if purpose is selected as 'business application' in catalog form and 'RTO' value present in service now application table for the selected server is 1 hour then RTO field on catalog form should be mandatory else it should not be .I have written below on change catalog client script and not sure what is wrong with this.could you please help here.
On change field :purpose
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('business_application_name', function(gr) { //business_application_name is reference field available for Applications.
if (gr) {
if (newValue == 'Business Application' && gr.u_rto == '1 Hour') { //u_rto column name of the field available on the service now application table
g_form.setMandatory('rto', true); //rto is name of the firld available on catalog form
} else {
g_form.setMandatory('rto', false);
}
//Type appropriate comment here, and begin script below
}
});
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 09:45 PM
try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Debug: Check newValue
console.log('Purpose newValue:', newValue);
g_form.getReference('business_application_name', function(gr) {
if (gr) {
// Debug: Check RTO value
console.log('Application RTO:', gr.u_rto);
// Adjust the value comparison as per your actual stored values
if (newValue == 'business_application' && gr.u_rto == '1 Hour') {
g_form.setMandatory('rto', true);
} else {
g_form.setMandatory('rto', 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
‎06-17-2025 09:45 PM
try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Debug: Check newValue
console.log('Purpose newValue:', newValue);
g_form.getReference('business_application_name', function(gr) {
if (gr) {
// Debug: Check RTO value
console.log('Application RTO:', gr.u_rto);
// Adjust the value comparison as per your actual stored values
if (newValue == 'business_application' && gr.u_rto == '1 Hour') {
g_form.setMandatory('rto', true);
} else {
g_form.setMandatory('rto', 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
‎06-18-2025 08:01 PM
Hope you are doing good.
Did my reply answer your question?
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