Catalog Client Script

DreDay3000
Tera Guru

Hello, I have a catalog client script that should display a message when a check box is unchecked after being checked.

 

Screenshot 2026-04-01 113307.png
When the box is unchecked, the error message should show

Screenshot 2026-04-01 113433.png

 This is the script I have so far: 

 
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    if (newValue == 'false') {
        g_form.showFieldMsg(has_call_activation_number_for_this_tree_been_added, 'CANNOT CONTINUE! All items in required information section MUST be met before continuing. Refer to Instructions for more information.', 'info');
    }
}

 

Screenshot 2026-04-01 113609.png

 Any help is greatly appreciated

 

 

1 ACCEPTED SOLUTION

pavani_paluri
Tera Guru

Hi @DreDay3000 ,

 

There are no quotes for variable/field you used in the script. Please use below updated script:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}

if (newValue === 'false') {
g_form.showFieldMsg(
'has_call_activation_number_for_this_tree_been_added',
'CANNOT CONTINUE! All items in required information section MUST be met before continuing. Refer to Instructions for more information.',
'error'
);
}
}

 

If your goal is to block submission until the checkbox is true, you might also want to use an onSubmit client script instead of just onChange. That way, you can prevent the form from being submitted until the condition is met.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

View solution in original post

6 REPLIES 6

Shaik Dimple
Tera Guru

 

Hi @DreDay3000 ,

 

Looks like the issue is with the field name in showFieldMsg. You missed quotes around it, so it won’t work.

It should be like this:

 
g_form.showFieldMsg('has_call_activation_number_for_this_tree_been_added', 'CANNOT CONTINUE! All items in required information section MUST be met before continuing. Refer to Instructions for more information.', 'info');

Field name should always be in quotes.

 

Regards,
Dimple Shaik

Tanushree Maiti
Kilo Patron

Try with this 

 

function onChange(control, oldValue, newValue, isLoading) {
     if (isLoading || newValue === '') {
        return;
    }    if (newValue == false && oldValue == true) {
        g_form.showFieldMsg('has_call_activation_number_for_this_tree_been_added', 'CANNOT CONTINUE! All items in required information section MUST be met before continuing. Refer to Instructions for more information.'', 'info');
         } }

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: