- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2023 01:48 AM
Hi, we have a field on our incidents called 'release date'. This is supposed to be filled in with a date in the future when a ticket is put 'on hold'. The ticket should then automatically come off hold on that date. I have setup a scheduled job to do this, however it's taking them off hold exactly 1 day later than the release date. For example, if I set the release date as tomorrow (10th of October), the ticket will not come off hold until the 11th. Here are the job details. Is there anything obvious that I'm missing? The script that it's executing is working, as I said the tickets are coming off hold at 5am, but for some reason 1 day late.
 
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 06:13 AM - edited ‎10-10-2023 06:16 AM
Hi @castle11
Just check the output of this script in you Background Script :-
If the time zone shown here is different, I assume that might be causing an issue
Can you try using GlideDateTime instead of new Date().
You can use this script. Check if it completely matches your use case.
The only case where this can fail(might and might not and depends on your scope) is, when you are using scoped application, subtract might not work and you should transfer it to a script include present in Global scope
var inc = new GlideRecord('incident');
// Get incidents with 'On Hold' state
inc.addQuery('state', 3);
inc.query();
var today = new GlideDateTime().getDate();
gs.log("Scheduled job running: Check on hold incidents");
while(inc.next()) {
// Convert the release date to GlideDateTime object then subtract the dates
var releaseDate = new GlideDateTime(inc.u_on_hold_release_date).getDate();
var dur = new GlideDuration();
dur = GlideDateTime.subtract(releaseDate, today);
var difference = dur.getDayPart();
// Check if the difference between the dates has 0 days
if(difference == 0) {
inc.u_on_hold_release_date = '';
// Set state as 'In Progress'
inc.state = 2;
inc.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 01:55 AM
Hey
If you want to speed up the process, you can edit the time(which is now at 5:00 am) & put a nearest time from now.
If it works fine, then you can keep it for tomorrow morning.
If you find it Helpful, please mark the answer as helpful so as to help others find this solution 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2023 02:13 AM
Looks to be working, thanks again for your help!