Need a schedule job to retire the record

suuriyas
Tera Contributor

HI Community,

 

I have a requirement, the software instances (cmdb_software_instance) table will be updating on the daily basics in our system. Now I need to write a schedule job to retire the software data/records which are not updated for the last 7 days.

 

How can we achieve this

11 REPLIES 11

HI @Ankur Bawiskar ,

 

I need to ran a schedule job to remove the install on from the software instances.

This software instances table is getting updated on daily basics if the records are not updated for last 7 days then i need to remove the install on from those records.

for example i have filtered out the install on by X and all the records are upadted more then 7 days so now i need to remove the install on from name (each of the record)

suuriyas_0-1744719077992.png

can you help me with that how can i achieve this

@suuriyas 

so what script did you start with?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

HI @Ankur Bawiskar ,

 

I have not started yet as the requirement got changed need to remove those and not to retire it

@suuriyas 

check below script.
I believe I have answered your question and you can take it further from here.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@suuriyas 

something like this should help, please enhance

(function() {
    var gr = new GlideRecord('cmdb_software_instance');
    var sevenDaysAgo = gs.daysAgoStart(7);
    gr.addQuery('sys_updated_on', '<', sevenDaysAgo);
    gr.query();
    while (gr.next()) {
        gr.setValue('software', ''); // clear the softward field
        gr.update();
    }
})();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader