Remove an option from a select box field

Leandro Oliveir
Tera Contributor

Hi everyone,

 

I need to remove an option from a select box field in a catalog client script by using sys_choice table.

The current Client Script is this:

 

function onLoad() {
g_form.removeOption('what_do_you_want', 'seasonal_campaigns');
//Qual material?
g_form.removeOption('what_material', 'ear');
g_form.removeOption('what_material', 'gradio_banner');
g_form.removeOption('what_material', 'board');
g_form.removeOption('what_material', 'plastic');
}

 

It's working but I need to change this script by using the sys_choice table itself with the conditions for the reference field to read only the values ​​that apply to the field.

How to achieve this?

2 ACCEPTED SOLUTIONS

Harsh_Deep
Giga Sage
Giga Sage

Hello @Leandro Oliveir 

 

Use select box and choose reference field as a choice table

Then add reference qualifier using script include.

 

That will work.

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Thanks

View solution in original post

Hi, 

Thanks for details, both the select box pointing to question_choice table where there is no dependency setup like sys_choice table. 

So first, create all qual material and qual problem label/value in Choice (sys_choice) table and setup dependency ( if applied ). 

second, re-configure both the catalog item variable with sys_choice table, after catalog form showing the data from sys_choice table then apply the removeOption logic.

 

As I understand , the qual problem depends upon qual material, so write a onChange client script on qual material field and apply removeOption base on matched condition.  

 

If( g_form.getValue("qual_material") == "putMatchedValueHere"){

g_form.removeOption("qual_problem" , "putTheRemoveValueHere" );

}

 

AshishKMishra_0-1697829873910.png

 

Let us know if it works for you or not. 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

8 REPLIES 8

Leandro Oliveir
Tera Contributor

The select box has its own question choices ( table: question_choice ).
It's used in a catalog item form:

 

LeandroOliveir_0-1697826611853.png

 

 

Hi, 

Thanks for details, both the select box pointing to question_choice table where there is no dependency setup like sys_choice table. 

So first, create all qual material and qual problem label/value in Choice (sys_choice) table and setup dependency ( if applied ). 

second, re-configure both the catalog item variable with sys_choice table, after catalog form showing the data from sys_choice table then apply the removeOption logic.

 

As I understand , the qual problem depends upon qual material, so write a onChange client script on qual material field and apply removeOption base on matched condition.  

 

If( g_form.getValue("qual_material") == "putMatchedValueHere"){

g_form.removeOption("qual_problem" , "putTheRemoveValueHere" );

}

 

AshishKMishra_0-1697829873910.png

 

Let us know if it works for you or not. 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Thanks @AshishKM !!
I managed to solve my problem with your solution, thank you very much.

Regards.

Good to hear back, thanks for confirming, happy to help.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution