- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 10:02 AM
I have written a script that I want to trigger an event when an incident is between 5 and 6 days old.
var sixdays = gs.daysAgo(-6);
var fivedays = gs.daysAgo(-5);
var target = new GlideRecord('incident');
target.addQuery('subcategory', "QNetwork");
target.addQuery('opened_at', '>=', sixdays);
target.addQuery('opened_at', '<=', fivedays);
target.addQuery('active', true);
target.query();
while (target.next()) {
gs.eventQueue("inl.qnet.inc.fivedaysold",target, gs.getUserID(), gs.userName());
}
If I comment out the five day query, I get back results for all tickets opened in the last six days. However with the five day query added back in I get no results when I should get back three.
What am I missing here?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 11:05 AM
var sixdays = gs.daysAgo(6);
var fivedays = gs.daysAgo(5);
var target = new GlideRecord('incident');
target.addQuery('opened_at', '>=', sixdays);
target.addQuery('opened_at', '<=', fivedays);
target.query();
while (target.next()) {
gs.print(target.number);
}
I did that and got records. I used 6 and 5, not -6 and -5.
I think negative with daysAgo is in the future.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 10:58 AM
Hi Brian,
I think you are not able to fetch the records as your and condition is not satisfied. You can check the same on the list view filter once. I think you have to change this to or condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 11:05 AM
var sixdays = gs.daysAgo(6);
var fivedays = gs.daysAgo(5);
var target = new GlideRecord('incident');
target.addQuery('opened_at', '>=', sixdays);
target.addQuery('opened_at', '<=', fivedays);
target.query();
while (target.next()) {
gs.print(target.number);
}
I did that and got records. I used 6 and 5, not -6 and -5.
I think negative with daysAgo is in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 11:13 AM
Thanks!
I knew it was something small I missed but just couldn't see.