Lookup multiple choice

omendersingh
Kilo Explorer

Hi

Anyone know how to set filter for a lookup multiple choice variable?

 

I want to display the values of replacement parts(lookup multiple choice) based on model selected.....

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Omender,



You can use reference qualifier to restrict the values as per the condition. Please check the below link for more info.


http://wiki.servicenow.com/index.php?title=Reference_Qualifiers#Simple_Reference_Qualifier_Example


Hi Pradeep,


I understand the reference qualifier and scripting the result, but I am needing to limit options from selections that are made on a form using variables.


This is the string that I am returning from a script to be the reference qualifier:


string = "category=604e09e26069210055dd239fccf49a07^u_print_color=" + variables.newprt_color + '"';



This does not work unless I put the actual value in the string instead of a variable. Its like it doesn't recognize the syntax. Is there a way to script this to be based on selections that is made on a form using variables in sc_cat_item?   If so, what would be the syntax and how would I get the reference qualifier to recalculate on each selection?   Hopefully this makes sense.



**I just added "current." to my variable and I did get the results to not display anything instead of displaying everything like it was before...making progress.



Thanks,


Trena


skendy
Tera Expert

Hi,



You can create a javascript like this (it depends from your needs):



var obj = new GlideRecord('u_TABLE_USED_THE_PRE_SELECTING');


      ctr.addEncodedQuery("field_nameSOME_FILTER_AND_CONDITIONS@javascript:gs.SOME_METHODS");


      ctr.query();




Hope it helps,


Skender


Thanks for the replies.   The problem that I am having is that I want to use variable values that are selected on the current form as the values for the javascript:<function()> in the reference qualifier that I am using in the Multiple Choice field to show only options that fulfil what the customer selects on the form.   I have several questions (variables) that get answered on the form and then once all questions are answered, the user would check a checkbox requesting the options that fit the criteria show up. Then the user would select one of the available options that display in the multiple choice variable.   The problem is the "javascript:wmc_filter_options()" that I have placed on the reference qualifier of the Multiple Choice variable gets the default values of the question variables which is "None" that I defined for it and not the values that the user selected.   I'm trying to figure out how to get the reference qualifier to use the current.variables.<variable name> that I have coded in the javascript function.   It seems to be a timing issue...how can I get the reference qualifier to use the values of the variables on the form when the user check the box to display the options?



Thanks in advance for your assistance.