Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

g_form.clearValue not working for select box variable

khareakshay
Tera Expert

I have a simple on change catalog client script as below, here entity_name is reference type variable,  changes_entity_appointment_ownership is select box variable and  appointments is MRVS and except for entity_name no other field gets cleared. I know appointments is MRVS and that can be the reason for it but How to resolve this for select box type variable?  

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

    g_form.clearValue('entity_name');
    g_form.clearValue('changes_entity_appointment_ownership');
    g_form.clearValue('appointments');

}
1 ACCEPTED SOLUTION
7 REPLIES 7

Nishant8
Tera Sage

Hello @khareakshay, Could you please verify whether you have None check box selected in the Select box variable? I believe, without this checkbox value will not be cleared; instead, it will be set to default value whatever was set when form loaded.

With None, system creates blank value and clear works.

 

Regards,

Nishant

Hi @Nishant8 ,
Yes I have none checkbox seleted.
My script works when I change the value of variable to something different but it did not work if I remove the selected value of variable.  FYI the variable on which this client script works is of type reference.

RaghavendraGund
Tera Contributor

Hello @khareakshay 
I replicated your scenario. exactly in my PDI. I created the Exact variables you mentioned in the question and also a MRVS.

Refer Screenshot Service catalog.
I created an on change client script as well.  For me it worked well.
MVRS - it cleared for me in every run, both renderers, model went to empty and the grid went back to No data to display.(please refer onchange client script screenshot)
Coming to changes_entity_appointment_ownership select box, if you have none checked in the type specifications of the variable, the script should clear the option you selected and fallback to none.
But, if you haven't checked none, by default it will fallback to the question choice with the lowest order.

please find the screenshot of the onchange client script i used in my  PDI. Modify according to your requirement it will work.

Please Mark Helpful, if my reply added any Value!!

Regards
Raghavendra G

Hi @RaghavendraGund ,
My script works when I change the value of variable to something different but it did not work if I remove the selected value of variable.  FYI the variable on which this client script works is of type reference.