Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set Reference Qualifier in Service Catalog item via onchange script?

jamesmcwhinney
Giga Guru

Within a service catalog item, within a variable's onchange script, is there a way to set the reference qualifier of another variable within the same catalog item?

Thanks!

- James

1 ACCEPTED SOLUTION

Try


javascript:new TravelPlanReferenceQualifier().setTheQualifier(current.variables.selected_destinations.toString())



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

14 REPLIES 14

Wow.   So when I accidentally wrote above that the mobile UI doesnt support advanced reference qualifiers, it turned out thats actually true.


Advanced reference qualifiers dont work in mobile either.


More and more I am beginning to feel that the mobile UI is so broken its not worth developing for.


To make anything work, the workarounds involved result in a solution that is so far from user friendly I am embarrassed to provide it..


1. Syncronous Ajax isnt supported


2. List Collectors arent supported


3. Advanced reference qualifiers arent supported


4. Subcategories arent supported


Almost there,. still struggling a little with this.



The following works:


Reference qualifier:


javascript:new TravelPlanReferenceQualifier().setTheQualifier()



Script include:


var TravelPlanReferenceQualifier = Class.create();


TravelPlanReferenceQualifier.prototype = {


      initialize: function() {


      },


  setTheQualifier: function() {


  return 'u_regions_coveredLIKEAF';


      },


      type: 'TravelPlanReferenceQualifier'


};



The following does not work (When i try to add a parameter):


Reference qualifier:


javascript:new TravelPlanReferenceQualifier().setTheQualifier(g_form.getValue('selected_destinations').toString())



Script include:


var TravelPlanReferenceQualifier = Class.create();


TravelPlanReferenceQualifier.prototype = {


      initialize: function() {


      },


  setTheQualifier: function(test) {


  return 'u_regions_coveredLIKEAF';


      },


      type: 'TravelPlanReferenceQualifier'


};


Try


javascript:new TravelPlanReferenceQualifier().setTheQualifier(current.variables.selected_destinations.toString())



Please mark this response as correct or helpful if it assisted you with your question.

Booyaa!   That was just what I needed.


Thank you!!!


Community Alums
Not applicable

this article worked for me:
How to modify Reference Qualifiers with Catalog Client Scripts – ServiceNow – ServiceNow Think (word...

 

 

and this is the onChange client script:

 

var resetFilter = 'active=true^nameISNOTEMPTY^emailISNOTEMPTY^EQ';
var dynamicFilter = g_form.getValue('your other text var holding encoded query').toString().trim();
var gg = g_list.get('your ref var name'); // GlideList2 object
gg.setQuery(newValue == '' ? resetFilter : dynamicFilter);