set reference qualifier through script for Lookup

sncrnd
Kilo Contributor

I am working on Eureka and looking help to set reference qualifier through script for Lookup Select box catalog variable. I have two variables:

  1. Application   - Select box
  2. Operation — Lookup select box

 

I put reference qual = "u_application_unit=" + current.variables.application for variable "Operation".

 

But this works only on load not on change of variable Application   variable. reference current.variables in the reference qualifier and have the field refresh when another variable changes

Can anyone help me how to do this.

 

Thanks

Chandan !

30 REPLIES 30

jeeva3
Mega Contributor

Please refer below link to set filter for list collector through client script


http://www.servicenowguru.com/scripting/client-scripts-scripting/changing-filter-list-collector-vari...


marcguy
ServiceNow Employee
ServiceNow Employee

I have a reference qualifier on a catalog item that is doing that now on change of a dependent variable as well, so I'm not sure why mine is working and yours isnt, you can use current like this....



javascript:getConfigGroups()




function getConfigGroups(){



  var app = current.variables.app; //this works on change for me i.e.: if I change the app, it brings a different set of groups when I lookup


    var gp = ' ';


    var grp = new GlideRecord('cmdb_ci_appl');


  if(grp.get(app)){


  if(!grp.u_configuration_manager_groups.nil()){


  var cfggroups = grp.u_configuration_manager_groups;


    return 'sys_idIN' + cfggroups;


    }


      }


  else {


  return 'active=true^u_configuration=true';


  }



}


jeeva3
Mega Contributor

I believe you are using reference qualifier on the variable of type "Reference". It is working for me in reference fields but not on variable type "lookup select box". I think because select box values are populated when the form is loaded itself, but reference field will query the options from server each time when we click on look up icon. Please correct me If I am wrong.


marcguy
ServiceNow Employee
ServiceNow Employee

yes you are correct, select box will only populate onload and won't respond to changes.



I'm sure I've seen a client script before to force the choice list to refresh though, i'll have a look now for it.


marcguy
ServiceNow Employee
ServiceNow Employee

This this, we are doing this on a field called u_service in a knowledge article but it may well work on catalog variables as well:



updateChoiceList_u_service() ;



swap u_service for the internal name of your variable



If it doesn't work then you might have to settle for a reference field instead of a choice list?