How to query doesn't contain in glide record.

jobin1
Tera Expert

Hi All,

 

How to Query does not contain in glide record. Tried below but not working.

 

Need to query "if a particular RITM no is not available in sc_req_item"

if (emailsubject.includes("RITM")) {
subject = emailsubject;
indexStart = subject.indexOf('RITM');
number = subject.slice(indexStart, indexStart + 12);
gs.log("custmint191" + number);

var sc_item1 = new GlideRecord("sc_req_item");

//sc_item1.addEncodedQuery('number NOT LIKE number');
//sc_item1.addEncodedQuery('number DOES NOT CONTAIN number');
//sc_item1.addEncodedQuery('numberNOT LIKE' + number);

sc_item1.query();

 

22 REPLIES 22

Hi @jobin1 ,

 

I have re-arranged the query. Try this one:

This translates to query RITM table and find records which either does not contains number or is not equal to number AND state is not one of closed complete/closed incomplete/closed skipped.

But this will only work if your requirement is also the same

 

var query = "number="+number+"^stateIN3,4,7,110"+"^ORnumberNOT LIKE"+number;

 

I Hope this helps.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh

Not working other state tickets also coming in this loop like wip/open/pending

 

var query = "number="+number+"^ORnumberNOT LIKE"+number+"^stateIN3,4,7,110";

@jobin1 ,

 

You have used the query wrong, let me re-iterate the query:

 

var query = "number="+number+"^stateIN3,4,7,110"+"^ORnumberNOT LIKE"+number;

kamleshkjmar_0-1666938290006.png

 

Regards,

Kamlesh