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.

Choice Selection from Reference Qualifier returns empty in Script Include when passing current

mballinger
Mega Guru

Hello,

I have a catalog item, and within the catalog, there is a specific variable that needs a reference qualifier. When building the reference qualifier, I am passing the current object. Within the Script Include, I am unable to access the value selected from a specific variable. The variable is a select box type with 2 choices.  

 

My reference qualifier is very simple:

 

 

javascript: new getAssetInfo().returnQuery(current);

 

 

 

My script include is also simple:

 

 

getAssetInfo: function(current) {
   var type = current.variables.type; // Select Box with 2 choices
   var user = current.variables.requested_for; //Reference field that returns sys_id

   gs.info("type: " + type); //returns empty
   gs.info("type: " + user); //returns sys_id
}

 

 

 

I am able to access the request for from current, but the select box is not outputting any data.

 

I've also tried current.variables.type.getDisplayValue() and that did not return anything

 

Anything Helps!

 

 

Thanks!

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

That reference qualifier can't work with that Script Include as the name of the SI needs to be getAssetInfo with a function named returnQuery, following the reference qualifier format.  Beyond that, I tried this in my PDI and was surprised it worked as 'type' is not the best choice for a script variable name since it could be a system/reserved word.  Are you certain 'type' is the variable name - no extraneous spaces or mis-spellings?

Thanks for your reply and my apologies the function name is returnQuery within the script include. Was just a typo. 

can you please provide an example of what you did in your PDI? My select box value is empty within script include 

BradBowman_0-1729205251641.png

BradBowman_1-1729205460611.png

 

 

 

var refQualUtils = Class.create();
refQualUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	getVars: function(current) {
		var type = current.variables.type;
		gs.addInfoMessage(type)
		return
	},
	
    type: 'refQualUtils'
});

 

BradBowman_2-1729205546834.png