Need a schedule job to retire the record
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 11:33 PM
why not use scheduled flow for this and no scripting required?
simply use Lookup Records on that table with conditions as Updated Before 7 Days
If you still require scheduled job then here is the sample script, 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('install_status', 'retired'); // Assuming 'retired' is the correct status value
gr.update();
}
})();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 12:25 AM
HI @Ankur Bawiskar ,
Thanks for the response,
I tried but it is not working, actaully in the software instances table we have only this fields and instal status is present in installed on
can you help me modifying this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 12:33 AM
I just provided sample script, you can enhance it further
do you want to query "cmdb_software_instance" or "software" table?
It's up to you but the logic for 7 days I already shared
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 12:48 AM
what's your actual requirement?
since your table "cmdb_software_instance" gets updated daily, are you saying if there is no record in this table for any software then that software record you need to update?
Remember there are 3 tables involved "cmdb_software_instance", "cmdb_ci" and "cmdb_ci_spkg"
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader