Restrict contextual search in catalog items to only record producers

ChrisWing
Mega Guru

I am trying to add contextual search to my catalog items.  I have made a lot of progress but I am now just attempting to restrict the results for this particular Catalog Item show only Record Producers.  Catalog Items and Standard Changes should be filtered out. 

 

I have created the following script

 

 

(function(current, query_table){
	/**
	 * current: A GlideRecord representing the Form or Record producer
	 * query_table: The table to compare value on
	 *
	 * Use the standard query features of GlideRecord to add conditions to query_table.
	 * Current prepresents the current values on the user's form or record producer that
	 * can be used to add live conditions to the query.
	 *
	 * E.g. query_table.addQuery("active", current.active);
	 *
	 * The return value should always be the encoded query, usually query_table.getEncodeQuery()
	 */
	
	query_table.addActiveQuery();
	query_table.addQuery(sys_class_name=RecordProducer);
	// Return the encoded query
	return query_table.getEncodedQuery();
})(current, query_table);

 

 

However it doesn't appear to be filtering.  I know this is the correct path as before with different syntax it broke the search, and now while it works it isn't filtering.  Appreciate any guidance to what I may have missed.

4 REPLIES 4

GlideFather
Tera Patron

Hi @ChrisWing 

 

Navigate to:

KamilT_0-1752791773213.png

 

Adjust existing or create new and with the related lists you should be able to achieve it.

 

Let me know how did it go

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Hey KamIIT,

 

I did set up a context as well, and even tried to filter it the way I wanted but it doesn't seem to be applying

 

ChrisWing_1-1753103432455.png

 

G Ponsekar
Mega Guru

Hi @ChrisWing ,

 

Can you try like this

query_table.addQuery("sys_class_name=sc_cat_item_producer");

 

instead of 

 

query_table.addQuery(sys_class_name=RecordProducer);

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

Hello,


That doesn't appear to be the solution.  In the screenshot below I am searching for a term Compass and only the circled one is a record producer the others are Standard Changes, and Catalog items.  I don't want either of those to show up yet even with that change they still do.
ChrisWing_0-1753103248674.png