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

Shishir Srivast
Mega Sage

Hello,



Are you trying in client script?


SanjivMeher
Kilo Patron
Kilo Patron

Try the below. But why are you querying the same thing in both conditions?



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) {


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


k++;


} else {


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


}


}


xx.query();



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

manishm
Mega Guru

Try this:



var xx = new GlideRecord("sn_customerservice_channel_config");


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


var k = 0;


var query;


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


if (k == 0) {


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


k++;


} else {


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


}


}


xx.query();



OR EVEN SIMPLER



var xx = new GlideRecord("sn_customerservice_channel_config");


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


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


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


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


}


xx.query();


Thank you guys!



To answer the why question ... cause the even simpler one is not so simple for everyone ... 😉


I'm a low code person ... ;-(



Anyhow .. I tried and the result is the same - not working as it will not work in a scoped application



log:


com.glide.script.fencing.ScopedQueryCondition.jsFunction_addOrCondition(ScopedQueryCondition.java:44)


sun.reflect.GeneratedMethodAccessor1175.invoke(Unknown Source)



How to do without the query.addOrCondition ???