Need a schedule job to retire the record
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 11:10 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 06:49 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 12:29 AM
Hi @suuriyas ,
You can use Schedule Job with with Run Weekly,
Code:
var retireSoftware = new GlideRecord('cmdb_software_instance');
retireSoftware.addEncodedQuery('sys_updated_on<javascript:gs.beginningOfLast7Days');
retireSoftware.query();
while(retireSoftware.next()){
retireSoftware.status='retired'; /// Assuming status is correct field and 'retired' is value
retireSoftware.update();
}