Restrict choices in Reference Field

kuttti
Kilo Guru

Hello,

I want to restrict reference field choices based on the selection of other variable(Select box) value. Any suggestions, please need help.

 

Thanks!

10 REPLIES 10

SNOW44
Mega Guru

By using Client callable  script include can use reference qul

function call(){ 
var gr = new GlideRecord('tabe of reference table');
         gr.addEncodedQuery("Pass Your required query");
         var arr = [];
        gr.query();
        while (gr.next()) {
            arr.push(gr.sys_id.toString());
        }
        // gs.info("Hi "+ arr);
        return  "sys_idIN" + arr ;
 }
    },
 
Go to dictionary of reference field and place in ref qul 
javascript:new scriptIncludeName().functionName();

Hi Raviteja,

This script is helpful. A small question, I am using this script on a multiple choice field and calling the Script include using on change client script, may I please know how should i get return value to the Onchange client script.  

 

Thanks!

DirkRedeker
Mega Sage

HI

I have one written Article about that:

https://community.servicenow.com/community?id=community_article&sys_id=834ebd4bdbb4d0901cd8a345ca961...

This will guide you step-by-step on how to accomplish that.

Let me know if that answers your question and mark my answer as correct and helpful.

BR

Dirk

 

Above article is helpful but I am trying achieve the functionality on choice variable and reference variable on catalog item not on tables.

 

Thanks!

Hi

Thanks for your feedback.

The way works pretty the same, you just need to set the Reference Qualifier on the catalog Variables (Reference Specification). Then it works the same.

Access the Catalog variables with

current.variables.your_cat_variable_name_goes_here

Give it a try and you will see, that it works the same.

Let me know if that answers your question and mark my answer as correct and helpful.

BR

Dirk