- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2017 12:58 PM
Hi all,
I'd like to use multiple addQuery statements in a GlideRecord to pick out records that meet both queries and then to have an event triggered by each record. However my line with the date query below is not working...seems to just ignore that line. Am I missing something for getting both addQuery statements to apply? Thanks!
var now = gs.nowDateTime();
var sd = new GlideRecord('change_request');
sd.addQuery('u_state','Pending Implementation');
sd.addQuery('sd.end_date', '<=','now');//this line does not seem to be applying to the query
sd.query();
while(sd.next()) {
gs.eventQueue('change.reminder.notify', sd, sd.number);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2017 01:22 PM
Use below script:
var query = 'u_state=Pending Implementation^end_date<javascript:gs.nowDateTime()'; // verify the original value of Pending Implementation state and replace that
var sd = new GlideRecord('change_request');
sd.addEncodedQuery(query);
sd.query();
while(sd.next()) {
gs.eventQueue('change.reminder.notify', sd, sd.number);
}
Thanks,
Arindam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2017 01:02 PM
remove the '' from now. addQuery('sd.end_date','<=', now); otherwise when doing this kind of stuff with time etc. I normally build the query in the listview, then copy the query and add it using addEncodedQuery() to get it right 😃
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2017 01:22 PM
Use below script:
var query = 'u_state=Pending Implementation^end_date<javascript:gs.nowDateTime()'; // verify the original value of Pending Implementation state and replace that
var sd = new GlideRecord('change_request');
sd.addEncodedQuery(query);
sd.query();
while(sd.next()) {
gs.eventQueue('change.reminder.notify', sd, sd.number);
}
Thanks,
Arindam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2017 03:44 PM
thanks Goran and Arindam!
I used Arundam's script and it worked great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2020 11:20 AM
Hey , i have also same issue but the data time is in a variable end and my addQuery does not work . Can anyone suggest ?
var gr1 = new GlideRecord('metric_instance');
gr1.addQuery('id',sysid);
gr1.addQuery('definition','35f2b283c0a808ae000b7132cd0a4f55');
gr1.addQuery('sys_created_on', '<=', end1); // this line does not work
gr1.query();