How to apply reference qualifier for Data Lookup Field

sidduab17
Tera Contributor

Hello Experts, I have two lookup select box fields in Catalog Item. First one is Country and another one is State. So when I select a country in Country field, then only states of that country should populate in State field using 'cmn_location' table data. To achieve this I have created one Script Include and called it in Reference Qualifier.

 

When I test this Script Include in Background Script, I'm getting only states of that country.

 

But when I call it in State lookup field using Reference Qualifier, I'm still getting all states are populated..

And I have attached screenshot for reference.

 

SS1 :- Variables

SS2 :- Script Include

SS3 :- Calling Script Include using Reference Qualifier

 

 

 

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@sidduab17 Instead of returning the state names, you should return the sys_ids of the state records.

Line number 12 should be replaced with

arr.push(gr.getValue('sys_id'));

Line number 14 should be replaced with

return 'sys_idIN'+arr.toString();

Hope this helps.

Amit Verma
Kilo Patron
Kilo Patron

Hi @sidduab17 

 

Assuming you have two lookup select box variables for Country and State respectively, you need to make use of the below Advanced Reference Qualifier in the State field to populate State based on country :

 

AmitVerma_0-1723624801526.png

 

 

javascript:"country="+current.variables.country.getDisplayValue(); //Assuming country is the name of the Country variable.

 

Output :

AmitVerma_1-1723624801463.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.