SYS Is not in query ?

sukran
Giga Sage

In Server side background script how to query glide record ... Sys Id is not ..

Below query is not working

var rec = incident.sys_id ( stored incident sysid records)

addQuery('sys_id , '!=', rec);

 

ANY IDEA

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hi @sukran,

 

Use the following query instead:

addEncodedQuery('sys_idNOT IN'+rec);

 

I am assuming the 'rec' variable is an array which stores the sys_ids.

 

Cheers

View solution in original post

11 REPLIES 11

Harsh_Deep
Giga Sage

Hello @sukran 

 

Please use below code

rec.addEncodedQuery('sys_id!='+rec);

 

Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Hi Harsh

rec.addEncodedQuery('sys_id!='+rec); its not returning correct data 

 

For Testing (I queried addQuery('sys_id' , rec) = > Its looks good 

But != condition not working 

 

can you post complete script code.

My Script code 

 

var exit = new GlideRecord('asmt_assessment_instance');

exit.addQuery('metric=22402a93030393976') // Metric rating

exit.query();

while(exit.next()){

var rec = exit.trigger_id ; // Sys id of engagement

 

var eng = new GlideRecord('sn_vdr_risk_asmt_vendor_engagement');

eng.addQuery('sys_id' , '!=' , rec);   ( Tried 'sys_idNOT IN ' +rec  and ('sys_id!='+rec)

eng.query();

while(eng.next()){

gs.print(eng,name);

}

}