Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Hiding Choices from one select box if a value is selected in another select box on Service Catalog

Tyler Johnson
Kilo Guru

I have been trying to hide specific values on a select box if Cloud is selected. I searched the community and found several posts regarding this however when i try to replicate i fail. Can you please help me determine where I'm messing up? 

 

The value for field 1 is 'type_of_environment' 

The value for field 2 is 'database_type'

 

if The value 'Cloud' is selected for field 1 then it should remove the choices in field 2 with the value of 'EMR' and 'SnowFlake'

 

ive also tried a UI policy as well with no luck. 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var reg = g_form.getValue('type_of_environment');
    if (reg == 'Cloud') {
        g_form.clearOptions('type_of_environment');
        g_form.removeOption('database_type', 'SnowFlake');
        g_form.removeOption('database_type', 'EMR');
    }
   
}
1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron

Hi @Tyler Johnson 

If you're using catalog item on the portal, let try to change the UI Type like below.

Timi_0-1708487077216.png

 

And your script could be like

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

    if (newValue == 'Cloud') {
        //g_form.clearOptions('type_of_environment'); //not sure about this line.
        g_form.removeOption('database_type', 'SnowFlake');
        g_form.removeOption('database_type', 'EMR');
    }else{
		//params: variable name, choice value, choice label
		g_form.addOption('database_type', 'SnowFlake', 'SnowFlake'); 
		g_form.addOption('database_type', 'EMR', 'EMR');
	}
   
}

 

 

Cheers,

Tai Vu

View solution in original post

1 REPLY 1

Tai Vu
Kilo Patron

Hi @Tyler Johnson 

If you're using catalog item on the portal, let try to change the UI Type like below.

Timi_0-1708487077216.png

 

And your script could be like

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

    if (newValue == 'Cloud') {
        //g_form.clearOptions('type_of_environment'); //not sure about this line.
        g_form.removeOption('database_type', 'SnowFlake');
        g_form.removeOption('database_type', 'EMR');
    }else{
		//params: variable name, choice value, choice label
		g_form.addOption('database_type', 'SnowFlake', 'SnowFlake'); 
		g_form.addOption('database_type', 'EMR', 'EMR');
	}
   
}

 

 

Cheers,

Tai Vu