- 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
05-06-2024 10:23 PM
Hi @Amit Pandey , Thanks for response
we do not have any filter type as do not start with in filters,
Thanks,
Sanath k
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 10:30 PM
Hi @sanathk
So sorry for the oversight.
You can use Starts with or does not contain instead. Can you write your exact requirement so that I can help you further.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 02:57 AM
HI @Amit Pandey , i need to write a schedule job that should close the Incident tickets that are not updated in past 30 days. This one i am trying to achieve through flow scheduled job.
In this i need handle this conditions
1.Incidents are not updated in past 30 days
2.Configuration item should not start with "Ex: ABC"
and then in update record i closing those fetched records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 03:33 AM
Hi @sanathk ,
For the question Configuration item should not start with "Ex: ABC" you can use SQL "NOT Like " operator.
gr.addQuery('name', 'NOT LIKE', 'ABC');
Hope this helps you in resolving your issue.
Thanks & Regards,
Anitha H V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 07:15 AM
Hi @1__AnithaHV , Thanks for your response ,
I have checked earlier, it will work in scheduled jobs but not in flow
Thanks,
Sanath K