- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 12:19 AM
Hello Community,
I have a requirement; I need to auto close the incidents which are not updated in last 30 days through schedule job which should run every day. can someone please help me with the code for this?
Thanks & regards,
Sanath K
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:02 AM
Hi @sanathk
I don't think this filter is possible in Flow Designer. You need to write a scheduled job. Sharing the outline of the code-
(function() {
var gr = new GlideRecord('incident');
gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(30));
gr.addQuery('cmdb_ci.name', 'NOT LIKE', 'ABC%');
gr.addQuery('active', true);
gr.query();
while (gr.next()) {
gr.setValue('state', 7);
gr.update();
}
})();
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:43 AM
Hi @Amit Pandey ,Thankyou so much for your support the above mentioned code will work and also we can do like this also.
var gr = new GlideRecord("incident");
gr.addEncodedQuery("encoded query with relevant conditions like updated on past 30 days");
gr.query();
while (gr.next()) {
if(!gr.cmdb_ci,name.startsWith("ABC",0){
gr.state = '7';
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 04:36 AM
Hi @sanathk
You can use the flow for the same.
Some baseline
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 02:52 AM
Hi @Dr Atul G- LNG , Thanks for your valuable response
The above mentioned solution is working fine but here i have a problem in condition i need to add a filter condition "does not start with" can you please guide me how can i achieve this in flow condition?
Thanks,
Sanath K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 09:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 10:12 PM
Hi @sanathk
You can create another filter by clicking on AND and then select the field you want to choose does not start with in trigger section.
Regards,
Amit