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

svirkar420
Tera Guru

Hi @DreDay3000 , Try adding condition like this.


if (oldValue == 'true' && 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');


The script that you are currently using does not check what the current or previous value of the field is. The above script should work.

 

If this response helped resolve your issue or question, please consider marking it as Accepted Solution and giving it a 👍.
This helps others in the community find useful answers more easily.

Regards,
Saurabh V.

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

yashkamde
Mega Sage

Hello @DreDay3000 ,

 

the mistake I'm able to see is only with the variable name as it is not quoted as a 1st parameter(<field_name>)..

replace this :

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'
);
}

 

Note : To provides a "hard stop" consider adding onSubmit catalog client script..

 

If my response helped mark as helpful and accept the solution.

Srikanth_9
Tera Guru

Hi @DreDay3000,

 

As @pavani_paluri mentioned you have missed to add quotes to the variable.

 

Please try with below code, I have done it in the PDI. 

 

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.', 'info');
    }

}
 
Please refer the attachments if needed.
 
If the provided solution is useful/working, please Accept as Solution and hit the Helpful. 
 
Thanks & Regards,
Srikanth Akula.