Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

addOrCondition not working ...

Zod
Giga Guru

HI .... as I'm using a scoped application I assume this might be the reason why the xx.addOrCondition gives me an error in the logs ... ;-(

" Cannot find function addOrCondition in object [object GlideRecord]."

Could you please help me doing what is done here ... just without requiring the   xx.addOrCondition ?

....

var xx = new GlideRecord("sn_customerservice_channel_config");

var arrXX = email.to.split(',');  

var k = 0;

for (var n = 0; n < arrXX.length; n++) {

if (k == 0) {

xx.addQuery('email_address', arrXX[n]);

k++;

} else {

xx.addOrCondition('email_address', arrXX[n]);

}

}

xx.query();

....

Thank you!!!

1 ACCEPTED SOLUTION

Can we try in this way. see if this helps.



var k = 0;


var queryString;


var arrXX = email.to.split(',');


var xx = new GlideRecord("sn_customerservice_channel_config");


for (var n = 0; n < arrXX.length; n++) {


if (k == 0) {


queryString = 'email_address=' + arrXX[n];


k++;


} else {


queryString = queryString + '^ORemail_address=' + arrXX[n];


}


}


xx.addEncodedQuery(queryString);


xx.query();


View solution in original post

22 REPLIES 22

this one does not work.


Will not find all entries ...



string 1 ( mail1,mail2,mail3) .... string 2 (mail1, mail1, mail1, mail2, mail5)



rowcount should find 4 entries ...  


antin_s
ServiceNow Employee
ServiceNow Employee

Did you try encodedQuery() ?


Try this. This should work



var xx = new GlideRecord("sn_customerservice_channel_config");


var arrXX = email.to.split(',');


qc = xx.addQuery('email_address', arrXX[0]);


for (var n = 1; n < arrXX.length; n++) {


qc.addOrCondition('email_address', arrXX[n]);


}


xx.query();



if (xx.next())


{


        gs.addInfoMessage('Record exists');


}



Please mark this response as correct or helpful if it assisted you with your question.

qc?


Corrected qc.




var xx = new GlideRecord("sn_customerservice_channel_config");


var arrXX = email.to.split(',');


var qc = xx.addQuery('email_address', arrXX[0]);


for (var n = 1; n < arrXX.length; n++) {


qc.addOrCondition('email_address', arrXX[n]);


}


xx.query();



if (xx.next())


{


        gs.log('Record exists');


}





Please mark this response as correct or helpful if it assisted you with your question.