- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2017 08:09 AM
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;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2017 08:13 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2017 08:17 AM
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;
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:58 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 01:32 AM
Thanks for the update. dan.bruhn..Can you please assist?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 08:35 AM
Hi Robbie,
Can you please confirm the action you are looking for? I don't see akunk23 requesting any action on this discussion.
Thanks,