Need to add more than 100 values for a dropdown variable.

Akshay Bhonde
Tera Contributor

I'm getting this requirement very frequently to add multiple choices under dropdown variable (I'm using Select Box) on catalog item form which is not referenced to any table. But it is not a best practice to add more than 15-20 values in select box variable type, and I also don't have option to refer to any table or I cannot add new table for every new catalog item. Can anyone please help what would be the best possible solution to achieve this, I'm writing the exact requirement below:

Need to create two variable -

1) Category - This has 10 dropdown values

2) Subcategory - It has more than 100 dropdown values for subcategory and that depends on category selected (Based on category value selected only related subcategories needs to be shown).

 

6 REPLIES 6

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello @Akshay Bhonde ,

                                              I'm unsure if this approach aligns with your needs, but there's a potential way to fulfil this requirement

You could store sub category value in script include and in on change client script based on category it will give us required sub category and then iterate in in client script and using g_form.addOption method we can set those in sub category field, Like below

Script include 

 

  var subcategories = [];
        
        // Logic to retrieve subcategories based on the selected category
        if (category == 'Category1') {
            subcategories = ['Subcategory1', 'Subcategory2', 'Subcategory3'];
        } else if (category == 'Category2') {
            subcategories = ['Subcategory4', 'Subcategory5', 'Subcategory6'];
        }
        
        return JSON.stringify(subcategories);

 

Kindly mark correct and helpful if applicable

Thanks Chetan for your reply.

But if in case some changes comes, will again need to go to the script and do it, I'm trying to achieve how Prince has suggested.

Prince Arora
Tera Sage
Tera Sage

@Akshay Bhonde 

 

1) If you don't have the table to store the choices, you can use the question_choice table to storing the values

For example: category value = "xyz"  ;  subcategory  Value= "Child_xyz"

 

2) Pick variable type as lookup select box and refer the table as "question choice", field as "Text"

 

3) Add reference qualifier script as:

javascript: getOptions(current.variables.category);

 

function getOptions(category){

return "question=SYSID_of_variable^valueendsWithcategory"; //please check the filter exactly from the table

}

 

I hope you will get the idea!!

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

@Akshay Bhonde 

 

I see you marked my answer helpful!!

Please Accept the solution if it works for you, it would be helpful for future readers too!