Catalog Item default variables

JohnMMcLaughlin
Tera Contributor

Hello,

I'm after some guidance on how to achieve the following.   We have a catalog item on our service portal, part of the form is below:

find_real_file.png

The bottom half of the form is made up of the 3 check boxes, now each checkbox has an underlying set of questions, see the screen shot below:

find_real_file.png

The issue I have is this, if a user selects the "SIM Card" checkbox as shown in the screen shot above, I want the default value for the "New/Replacement SIM" question to be New, which it is, the problem is as the default value is "New" even if the user doesn't select the SIM Card checkbox the "New or Replacement SIM" variable is still set as "New" the default value, this then means I get the next screen shot when looking at the request item (the screen shot is for the Mobile Phone question, but the issue is the same)

find_real_file.png

Now what I would like to achieve is have no default variables set until the user selects the checkbox, so going back to the "SIM Card" checkbox, if the user doesn't select the "SIM Card" checkbox, the "New or Replacement SIM" variable doesn't have a default value (and therefore doesn't show in the options panel of the request item), but if the user does select the "SIM Card" checkbox, then the "New or Replacement SIM" variable should have the default value of "New".

I hope that all makes sense, and if not let me know and I will try and better explain the issue.

Thanks in advance.

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



The best way to do control this in a client script running onChange on the SIM Card variable



In the client script do someting like this



if (newValue == false) {


        //Clear all radio buttons when checkbox is cleared


        g_form.setValue('new_var','');


        g_form.setValue('replace_var','');


        g_form.setValue('cancel_var','');


        return;


}


var new = g_form.getValue('new_var');


var replace = g_form.getValue('replace_var');


var cancel = g_form.getValue('cancel_var');



//Set default value if no radio button is selected


if (new == '' && replace == '' && cancel == '')


        g_form.setValue('new_var',true);


View solution in original post

4 REPLIES 4

larstange
Mega Sage

Hi



The best way to do control this in a client script running onChange on the SIM Card variable



In the client script do someting like this



if (newValue == false) {


        //Clear all radio buttons when checkbox is cleared


        g_form.setValue('new_var','');


        g_form.setValue('replace_var','');


        g_form.setValue('cancel_var','');


        return;


}


var new = g_form.getValue('new_var');


var replace = g_form.getValue('replace_var');


var cancel = g_form.getValue('cancel_var');



//Set default value if no radio button is selected


if (new == '' && replace == '' && cancel == '')


        g_form.setValue('new_var',true);


Hi Lars,


We use many of these "onChange" client scripts on our catalog items, and now we are thinking of making the catalog available :


- on service portal (today it is only available on CMS and back office)


- on mobile



Will these client scripts still work fine?


Thank you!


Hi



Yes they will work, but there are certain limitations - see here for details: Service Portal Documentation


JohnMMcLaughlin
Tera Contributor

Lars,



Sorry for the delay in responding.   This was exactly what I was after.



Thanks.