Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to fetch records which are having scheduled retirement date in next 3 months from now?

Sreeja3
Giga Contributor

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

9 REPLIES 9

Omkar Mone
Mega Sage

Hi 

Do you have any Due date or some field like that which auto populates date after 3 months of selected date?

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

Alikutty A
Tera Sage

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!

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