Catalog Variable add Option Help?

Community Alums
Not applicable

Hi Community,

Need help, I have a variables set, one variable 'Office Location' is reference to cmn_location table and another variable 'ttt' is 'select box' type in which I have added question choices. 

The requirement is when the 'Office Location' is china > I have to show option in 'xxx' as > aaa, bbb, Other (default = aaa).

Appriciate any help!

I tried this script but no luck. 

Regards,

Rafmine.

 

1 ACCEPTED SOLUTION

I tried to simplify your script. Try below script.

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

    alert('loopin');
    g_form.clearOptions('office_location');
    g_form.getReference('office_location', callback);

    function callback(gr) {
        if (gr.name == 'France') {
            g_form.addOption('laptop_keyboard_layout', 'Azerty FR', 'Azerty FR');
            g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
        } else if (gr.name == 'United Kingdom') {
            g_form.addOption('laptop_keyboard_layout', 'Qwerty UK', 'Qwerty UK');

        } else {
            g_form.addOption('laptop_keyboard_layout', 'Azerty BE', 'Azerty BE');
            g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
        }
		g_form.addOption('laptop_keyboard_layout', 'Other', 'Other');
    }
	
	alert('loopout');
	
}

 

Hopefully, this will work for you.

View solution in original post

6 REPLIES 6

Mohith Devatte
Tera Sage
Tera Sage

Hello ,

I think in the alert you have to put the text in quotes like alert('loopin');

This might stop the execution of the script at this line .

so may be becoz of this its not executing the further script .

Place it in quotes and try

Hope this helps

Please mark my answer correct if this helps you

Community Alums
Not applicable

Hi Mohith,

Thanks for answering my post, I tried with test quotes but no luck, not sure where i'm going wrong. can you help me?

Regards,

Rafmine

Yousaf
Giga Sage

Hi Rafmine,

What Mohith said will solve your problem I think. Still if it doesnt here is a good example of making values dependent using client scipt.

Creating Dependent Variables in Service Catalog? Here are two ways how it can be done.

 

Mark Correct or helpful if it helps.


***Mark Correct or Helpful if it helps.***

Muhammad Khan
Mega Sage

Hi,

You are using g_form.getDisplayValue('office_location'); which seems to be a problem to me.

Try using below script.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
        g_form.getReference('office_location', callback);
}

function callback(gr) {
    if (gr.name == 'United Kingdom'){
        // Your logic here.
    }
}