- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:25 PM
Hi Team,
How to achieve ,If the Work Order Task is not closed/rejected within 5 days, it should automatically close.
using Scheduled Jobs.
Regards,
Abhilasha G T
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 04:44 AM
Hi Maik,
Thank you for the reference video you have shared , but there will be constrains to close the WOT form ,some mandatory fields need to fill before closing the task,
there is a BR/Scripts for those mandatory fields , am not supposed to disable those scripts
so need the suggestion without disturbing those script how can achieve.
Regards,
Abhilasha G T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:42 AM
The above code is Tested just change the field names
var taskGr = new GlideRecord('task');
taskGr.addActiveQuery();
taskGr.query();
while (taskGr.next()) {
var taskOpenedDate = taskGr.sys_created_on;
var taskopen = new GlideDateTime(taskOpenedDate);
var currentDate = new GlideDateTime();
var differenceInDays = (currentDate.getNumericValue() - taskopen.getNumericValue()) / (1000 * 60 * 60 * 24);
if ((taskGr.state != 3 && taskGr.state != 7) && differenceInDays >= 5) { // Check if not closed or rejected and open for more than 5 days
//Perform automatic closure logic here
taskGr.setValue('state', 6); // Set the state to 'Closed' (assuming '6' is the code for 'Closed')
taskGr.update();
}
}
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Prashant Ahire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:44 AM - edited 12-07-2023 01:46 AM
HI @Abhilasha G T The above code is Tested just change the field names
var taskGr = new GlideRecord('task');
taskGr.addActiveQuery();
taskGr.query();
while (taskGr.next()) {
var taskOpenedDate = taskGr.sys_created_on;
var taskopen = new GlideDateTime(taskOpenedDate);
var currentDate = new GlideDateTime();
var differenceInDays = (currentDate.getNumericValue() - taskopen.getNumericValue()) / (1000 * 60 * 60 * 24);
if ((taskGr.state != 3 && taskGr.state != 7) && differenceInDays >= 5) { // Check if not closed or rejected and open for more than 5 days
//Perform automatic closure logic here
taskGr.setValue('state', 6); // Set the state to 'Closed' (assuming '6' is the code for 'Closed')
taskGr.update();
}
}
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Prashant Ahire