Fetching records between two dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 01:37 PM
Hi ,
I am trying to fetch data based on two dates but not getting any results.
Can you update me where i am doing mistake or any option to fetch data.
where alert_bin_value and alert_app_value are alert's bin and application name.
var alert_created_1=gr.sys_created_on.getDisplayValue();
var dateTime = new GlideDateTime(alert_created_1);
dateTime.addSeconds(-1800);
var modifyAlertCreatedate=dateTime;
var inc1 = new GlideRecord("incident");
inc1.addEncodedQuery("assignment_group.name="+alert_bin_value+"^u_application.name="+alert_app_value+"^stateIN1,2,3^sys_created_onONLast 2 hours@javascript:gs.beginningOfLast2Hours()@javascript:gs.endOfLast2Hours()");
inc1.addQuery('sys_created_on','>',modifyAlertCreatedate);
inc1.addQuery('sys_created_on','<',alert_created_1);
inc1.orderByDesc('sys_created_on');
inc1.query();
Please help.
- Labels:
-
Field Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 04:17 PM
Hi, have you debugged\printed your result to screens in order to see whats going on
I see the first line list here var alert_created_1=gr.sys_created_on.getDisplayValue();
But don't see gr defined anywhere, is there an initial line of script where gr is defined IE var gr = new GlideRecord (of some sort)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 09:52 PM
This is alerday defined in starting of code.
var gr = new GlideRecord ('em_alert)
We are fetching some open alerts which has no incident copied only . and for each alerts i want to fetch incident.
Please check and help to identify where is miss as no data is coming.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 09:53 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 10:37 PM
Hi Anil,
I suggest you print the values of these variables alert_bin_value, alert_app_value,modifyAlertCreatedate,alert_created_1 and run this in background once with static values and see if you are getting any data.
Most probably one of the variables below might not be matching the condition.
Mark the answer as correct/helpful if you find this helpful
This is alerday defined in starting of code.
var gr = new GlideRecord ('em_alert)
We are fetching some open alerts which has no incident copied only . and for each alerts i want to fetch incident.
Please check and help to identify where is miss as no data is coming.