Filter A LookUp SelectBox by a Single Line Text

Markell
Tera Guru

Hi Guys 

I have tried a few things but I seem to be getting nowhere.

I simply want to filter this LookUp SelectBox (Subcategory) dependant value in the sys_choice table by the Single Line Text field (Category Label)

Markell_0-1762263287568.png

Bit of context: I was having a nightmare trying to filter directly via the other LookUp SelectBox (Category) but when I did A script include and hard coded the Category as 'End User Hardware' the filter worked!
So now I'm trying to just simply filter by a string.

I am currently just seeing if the following reference qualifier will work:

javascript:
var label = current.variables.category_label;
'inactive=false^element=subcategory^sys_domain=global^name=incident^dependent_value=' + label + '^ORDERBYlabel';

Markell_2-1762263635010.png

 

 

Any help welcome

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Markell 

it should work provided you have dependent subcategory for those categories and you added variable attribute as this in lookup select box variable

ref_qual_elements=category_label

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

5 REPLIES 5

apelluru
Tera Contributor

Hi, 

Can you troubleshoot below steps?

1) Make sure category_label is the correct variable name and available in current.variables.
2) Confirm the label exactly matches the dependent values in the sys_choice table (“End User Hardware” or whatever string you use). I hope its works because you said its working when you hardcoded. 

and your approach is perfect—just confirm the variable names and values match the sys_choice table. 

yea the label is defo the correct one Ive tried label and value and tbf they are both set to the same string value anyway.


apelluru
Tera Contributor

Ok hmmmm.  few more debugging points from my end. 

1) Ensure that category_label is accessible in the scope where your reference qualifier is running.

2) 

As you did before, set the dependent_value in your filter to the exact string (e.g., 'dependent_value=End User Hardware') to confirm the filter itself works. 

 

3) Can you see what is gs.info(label) from logs?

apelluru
Tera Contributor

Hi, 
Can you troubleshoot below steps?

1) Make sure category_label is the correct variable name and available in current.variables.
2) Confirm the label exactly matches the dependent values in the sys_choice table (“End User Hardware” or whatever string you use). I hope its works because you said its working when you hardcoded. 

and your approach is perfect—just confirm the variable names and values match the sys_choice table.