Glide Record Notification

akunk23
Kilo Contributor

I'm very new to using GlideRecord. I'm writing an advanced condition to specify when to send an email notification. Right now my script is working for the "Field" notification(I'm not wanting to send the notification then). But now I need to add another statement to check if the sc_req_item is "IT"(and also not send the notification)... How would I add an OR statement to my script to include "IT". Thanks in advance

var gr= new GlideRecord("sc_req_item");

gr.addQuery("cat_item.name","Field");

gr.addQuery("request",current.getValue("sys_id"));

gr.query();

if(gr.next()){

answer=false;

}

else{

answer=true;

}

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi akunk23,



See this link, this will provide you with what you're after:


http://wiki.servicenow.com/index.php?title=GlideRecord#addOrCondition



It should look something like below if 'IT' is the name of the item.




var gr= new GlideRecord("sc_req_item");


var qc = gr.addQuery("cat_item.name","Field");


qc.addOrCondition('cat_item.name', 'IT');


gr.addQuery("request",current.getValue("sys_id"));


gr.query();


if(gr.next()){



answer=false;


}


else{


answer=true;


}



For future GlideRecord querying, also see these links.


Also see 'Encoded Queries' and how to generate an encoded queries:


http://wiki.servicenow.com/index.php?title=GlideRecord#addEncodedQuery


Encoded Query Strings - ServiceNow Wiki




Thanks,


Robbie



Please mark correct and helpful by clicking on your post link (Glide Record Notification ) to help others with the same/similar question.


View solution in original post

8 REPLIES 8

Harish KM
Kilo Patron
Kilo Patron

var gr= new GlideRecord("sc_req_item");


gr,addQuery("request",current.getValue("sys_id"));


var qc = gr.addQuery("cat_item.name","Field");


qc.addOrCondition("cat_item.name","IT");


gr.query();


if(gr.next()){



answer=false;


}


else{


answer=true;


}


Regards
Harish

Robbie
Kilo Patron
Kilo Patron

Hi akunk23,



How did you go?


Did you see my response above? 1st response in the thread...



Thanks,


Robbie



Please mark correct and helpful by clicking on your post link (Glide Record Notification ) to help others with the same/similar question.


Robbie
Kilo Patron
Kilo Patron

Thanks for the update. dan.bruhn..Can you please assist?


Hi Robbie,



Can you please confirm the action you are looking for?   I don't see akunk23 requesting any action on this discussion.



Thanks,