Using Reference qualifier, to trigger based on value selected in another dropdown

meher_sanjiv
Kilo Expert

Hi All,

I have two Lookup Select Box fields (drop down), Server Type and C Drive on a Service Catalog form. Both reference to the same table which has type and GB field.

I have set a reference qualifier to set dropdown values for 'C Drive', based on Server Type Selection.

But it doesn't work as expected.

If I select, Server Type as 'Application', it should set the drop down as values 100,200 etc, based on values in the reference table.

If I select, Server Type as 'Database', it should set the drop down as values 150,200 etc, based on values in the reference table.

But the reference qualifier doesn't trigger, when we change the Server Type. It only works, when Server Type is already populated, when I open the order form.

The reason I am using reference qualifier is, I am also using Price to get auto-updated based on 'C Drive selection'.

1 ACCEPTED SOLUTION

johnlampson
Giga Contributor

Hi Sanjiv Meher



I've done this by setting a reference qualifier on the second lookup select box that calls a script include.



EDIT: In the attributes field, you'll put "ref_qual_elements=server_type"



The reference qualifier you'll put on the "C: Drive" variable lookup select box will look like:



javascript:new ScriptIncludeName().CheckServerType().



Presuming your variable for server type is server_type, the script include will look like:



var ScriptIncludeName = Class.create();


ScriptIncludeName.prototype = {


  initialize: function() {


  },



CheckServerType:function(){


  var server_type = current.variables.server_type;


  return 'u_active=true^u_server_type=' + server_type;


  },



  type: 'ScriptIncludeName'



};






Does this help?



John


View solution in original post

7 REPLIES 7

manikorada
ServiceNow Employee
ServiceNow Employee

Sanjiv,



Can you check if there are any browser errors?


meher_sanjiv
Kilo Expert

No Mani. I dont see any error. I have checked other posts, and most of them says, a Select Box is only loads during onLoad. I was wondering if there is any way to trigger the reference qualifier to run again on the C Drive field.


Victor Ruiz
Tera Guru

I believe KP Kalaiarasan P may have what you're looking for in this post: Reference Qualifier on Lookup Select Box Variable


johnlampson
Giga Contributor

Hi Sanjiv Meher



I've done this by setting a reference qualifier on the second lookup select box that calls a script include.



EDIT: In the attributes field, you'll put "ref_qual_elements=server_type"



The reference qualifier you'll put on the "C: Drive" variable lookup select box will look like:



javascript:new ScriptIncludeName().CheckServerType().



Presuming your variable for server type is server_type, the script include will look like:



var ScriptIncludeName = Class.create();


ScriptIncludeName.prototype = {


  initialize: function() {


  },



CheckServerType:function(){


  var server_type = current.variables.server_type;


  return 'u_active=true^u_server_type=' + server_type;


  },



  type: 'ScriptIncludeName'



};






Does this help?



John