Client Script setting a checkbox to true is not working

Jazz5
Kilo Expert

Hello all,

I have multiple choice field, with three choices.  The following client script does not seem to work. I want to set a checkbox to true depending on the multiple choice selected on the catalog item,

Type is onchange

 

find_real_file.png

find_real_file.png

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

if (newValue == 'OTC') {
g_form.setValue('otc_lm_cash', 'true');
}

else if (newValue == 'RTR') {
g_form.setValue('rtr_icrecon', 'true'); g_form.setValue('rtr_lm_cash', 'true');
}

else if (newValue == 'PTP') {
g_form.setValue('payment_processing', 'true');
}
}

14 REPLIES 14

Sushma R1
Tera Expert
Do you want to consider passing. Boolean instead of string 'true'. I mean just remove the quote for true n try. Good luck Hit helpful if it was 🙂

Saurav11
Kilo Patron
Kilo Patron

Hello,

You need to set the checkbox value without putting true inside the inverted commas

Please use the below:-

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

if (newValue == 'OTC') {
g_form.setValue('otc_lm_cash', true);
}

else if (newValue == 'RTR') {
g_form.setValue('rtr_icrecon', true);

g_form.setValue('rtr_lm_cash', true);
}

else if (newValue == 'PTP') {
g_form.setValue('payment_processing', true);
}
}

 

Please mark answer correct/helpful based on Impact

Hey @saurav

Please do not duplicate the thread answer by giving the same reply which I have already provided above.

Would suggest please go through the thread before posting your comments in.

 

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

When I opened the thread there was no replies on it, till I finished typing and clicked on reply there were multiple answers already, so not really did i had a chance to read the thread as there was none when I opened it.

But still will delete my answer.

Cheers!!!

Hitoshi Ozawa
Giga Sage
Giga Sage

Checked with the following script. I've added code to uncheck choices that were selected by earlier choices.

function onChange(control, oldValue, newValue, isLoading) {
    if (newValue == '') {  // deleted onloading so default choice will run
        return;
    }

    if (newValue == 'OTC') {
        g_form.setValue('otc_lm_cash', 'true');
        g_form.setValue('rtr_icrecon', 'false');
        g_form.setValue('rtr_lm_cash', 'false');
        g_form.setValue('payment_processing', 'false');
    } else if (newValue == 'RTR') {
        g_form.setValue('otc_lm_cash', 'false');
        g_form.setValue('rtr_icrecon', 'true');
        g_form.setValue('rtr_lm_cash', 'true');
        g_form.setValue('payment_processing', 'false');
    } else if (newValue == 'PTP') {
        g_form.setValue('otc_lm_cash', 'false');
        g_form.setValue('rtr_icrecon', 'false');
        g_form.setValue('rtr_lm_cash', 'false');
        g_form.setValue('payment_processing', 'true');
    }
}

I've set OTC as the default choice on variable "wipro_tower_2".

Execution result:

find_real_file.png

find_real_file.png

find_real_file.png