The CreatorCon Call for Content is officially open! Get started here.

Catalog Item - Select Box variable dependent on other select box variable.

Bindu Jayagond
Tera Contributor

Hello,

 

I have created  a catalog item in which Question 1 type is select box, if here user selects an option based on that Question 2(select box) options should be shown.

 

I tried to achieve this with help of client script (type - onchange) using addOption() and removeOption().

 

This is not working properly when I select option 1 from Question1 then change is in seen in the Question 2 option but when I immediately change the Question1 to option2 the options for Question2 is not changed unless I don't refresh the service portal form.

 

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

Because of this possibility/likelihood that the value for Question1 could change more than once, your script needs to comprehensively account for each value.  We do this in an onChange script with a series of if statements that get rid of all options, then adds back the appropriate ones like this:

 g_form.clearOptions('v_inquiry_subtype');
    if (newValue == 'Connectivity') {
        g_form.addOption('v_inquiry_subtype', '', '-- None --');
        g_form.addOption('v_inquiry_subtype', 'activation', 'Activation / Re-Activation');
        g_form.addOption('v_inquiry_subtype', 'roaming', 'Roaming / International');
     }
    if (newValue == 'Hardware') {
        g_form.addOption('v_inquiry_subtype', '', '-- None --');
        g_form.addOption('v_inquiry_subtype', 'sim_replace', 'SIM card replacement');
     }
    ...

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Bindu Jayagond 

check this link and this should help you

Using Category and Subcategory on ServiceNow Record Producers 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for your link . The Article is very helpful.

Aishwarya27
Tera Contributor

Hi @Bindu Jayagond 

 

Please refer to this article  I thought  this will be work

for your Requirements

https://www.servicenow.com/community/itsm-articles/category-subcategory-dependency-in-service-catalo...

 

Thanks !