Trying to return variables to a list collector based on catalogue item selected in a reference field

Steven Watts2
Tera Guru

Hi,

I'm trying to return a list of variables to a list collector based on a selection made in a reference field to the sc_cat_item table. I.e., the requestor selects the catalogue item and the 'variables to be removed' variable only displays the variables attached to that item. See screenshot below.

 

StevenWatts2_0-1679415874951.png

 

I've updated the reference qualifier on the list collector to - 

javascript: 'sys_idIN' + new GetCatItemDetails().getVariables(current.variables.catalogue_item_to_be_updated);

This is calling a script include function - 

getVariables: function(catItem) {
		
		var vars_array = [];
		var getVars = new GlideRecord('item_option_new');
		getVars.addQuery('cat_item', catItem);
		getVars.query();
		while (getVars.next()) {
			var varsSysId = getVars.getValue('question');
			vars_array.push(varsSysId);
		}
		return vars_array;		
	},

Can anyone see where I am going wrong as the variable always comes back with 'No matches found'.

 

Steven

1 ACCEPTED SOLUTION

@Steven Watts2 ,

 

Got it!

Please do this in reference qualifier, it will work 100%:

javascript: 'cat_item=' + current.variables.your_term_variable_name_here;

PRINCE_ARORA_0-1679492866415.png

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

8 REPLIES 8

@Steven Watts2 ,

 

Got it!

Please do this in reference qualifier, it will work 100%:

javascript: 'cat_item=' + current.variables.your_term_variable_name_here;

PRINCE_ARORA_0-1679492866415.png

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Thanks for all your help. That has worked spot on :).

 

Steven

Dhruv Chandan
Giga Guru

Hi,

 

Could you try the below code :-

 

getVariables: function(catItem) {
		
		var vars_array = [];
		var getVars = new GlideRecord('item_option_new');
		getVars.addQuery('cat_item', catItem);
		getVars.query();
		while (getVars.next()) {
			var varsSysId = getVars.getValue('sys_id');
			vars_array.push(varsSysId);
		}
		return String(vars_array);		
	},

 

Hope this helps.

 

Regards,
Dhruv

Steven Watts2
Tera Guru

Hi,

 

Thanks for the assistance. Unfortunately i'm getting the same issue. Might just add a multiline string variable and let them enter the questions.

 

Thanks.