How to fetch records which are having scheduled retirement date in next 3 months from now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 11:39 PM
Hi Team,
I have a requirement to fetch the records from cmdb_ci_computer table which is having asset.retirement date within 3 months from now.
Initially we were asked to fetch the records having retirement date on next week so I queried form the filter directly.
Here is the script
var gr = new GlideRecord('cmdb_ci_computer');
gr.addEncodedQuery('asset.install_statusNOT IN7,8^asset.retirement_dateBETWEENjavascript:gs.beginningOfToday()@javascript:gs.endOfNextWeek()');
gr.query();
while (gr.next()) {
gs.eventQueue("assignto_asset_refresh_event", gr);
}
But I have no idea how can I fetch the records having retirement date 3 months from now.
Any help would be highly appreciated. Thanks in advance.
Regards,
Sreeja
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 11:42 PM
Hi
Do you have any Due date or some field like that which auto populates date after 3 months of selected date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 12:09 AM
No field is there Omkar.
I have to query that and fetch all the records having retirement date within 90days or within 3 months.
Regards,
Sreeja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 11:51 PM
Hi,
You can apply this filter on your CI table and verify the records first.
Asset.scheduled retirement relative on or before 3 months from now
Once you verified the results, copy the query and replace it in your script.
Sample query: asset.retirement_dateRELATIVELE@month@ahead@3
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 12:08 AM
Hi Alikutty,
Thanks for your response. I tried with the relative operator but its fetching all the record on or after 90 days. But I want the records having retirement date within 90 days.
Any idea how can I do that?
Regards,
Sreeja