Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Can I set a Reference Qualifier Condition in a Catalog Client Script?

Joe Weisiger
Giga Expert

Hello,

I am creating multiple catalog items which all use a shared variable set.  I am looking for a way to set a Reference Qualifier Condition via a Catalog Client Script.  Is this possible and if so how do I code it?

Thank you,

Joe

1 ACCEPTED SOLUTION

Not applicable

Hey,

sorry, my bad - add after line 17 one more "}" - the entire method is not actually enclosed hence we get this error.

 

Joro

 

P.S. Sorry for the delay - my actual email is not the one pointed in my account so I dont get notifications (and I cant change it sadly)  😞

View solution in original post

16 REPLIES 16

Hi Joro,

I don not actually see literal example in my code above.

Probably, i mislead you by only pasting one function form actual code.

Please let me know if i missing something.

Here I am using same approach as you mentioned in your answer - a common Script Include class: 

 

/*jshint esnext: true */
var CIQualifier = Class.create();
CIQualifier.prototype = {
....
//methodPerCatalogItems
...

	type: 'CIQualifier'
};

CIQualifier.filterForRequest = function(requestId, currentObj) {
var instance = new CIQualifier(currentObj), filter = "";

var  configurationVerification = "1fc0c8191360e70076dcb3776144b032",
		zoning = 'cc35c6133777b100b94d27d2b3990ea6',
                move = '2a4526d30f1331001820e388b1050e0b',
                ....;

switch(requestId.toString()){
		case configurationVerification:

			filter = instance.configurationVerificationCollector();
			break;

		case zoning:
			filter =  instance.zoneEquipQualifier();
			break;
.........


	return filter;
};

 

entire g_form  is not needed so we can pass the actual object of interest as param to the method

That is true, but if you have often requirements change 
I prefer all my asset qualifiers looks as
javascript:CIQualifier.filterForRequest(current.cat_item, current);

and fully have logic moved into  CIQualifier.

This give no redundant modifications of variable record + all qualifier changes are store and review  centralized.

 

 

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);