'IN' GlideRecord Query Not Working as Expected

codedude
Mega Expert

I have a query that I have written that is looking at a Tag field on the sc_cat_item table. This Tag field is a comma delimited field, for instance it would look like this (apple, laptop, desktop, hp, hardware).

My query looks like this:

var searchParameters = document.getElementById("searchParams").value;

var myNewStr = searchParameters.replace(/ /g,', ');

var scSearch = new GlideRecord('sc_cat_item');

scSearch.addQuery('active', 'true');

scSearch.addQuery('u_tag', 'IN', myNewStr );

scSearch.setLimit(5);

scSearch.orderByDesc('sys_updated_on');

scSearch.query();

If I were to type in "this is my apple" The myNewStr returns this "this, is, my, apple" and I would expect the query to return 1 result, because 1 catalog item has a tag that is named apple.... but it is returning 0 results, why is it not returning anything?

Am I misinterpreting the IN in GlideRecord? I also used CONTAIN and it did not work either...

Any advice?

20 REPLIES 20

Thanks for the clarification. Go forth and prosper young man!