- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 08:51 AM
I am working on setting up an Inbound Action that kicks off an Incident. I am on EST.
If the email that kicks off the Inbound Action is received between M-F 8am-4pm then I want the ticket to be assigned to the ATM Settlement group, if it comes in any other time then it should go to the ATM Services group.
I put the script below together (with assistance from ChatGPT). It kicks off the incident correctly but it is still a bit off with the time. For example, when I ran it at around 10:30am on a Thursday in September, when I look in the logs it said the current hour was 9 and that DST in effect was False (we are currently on DST)
Any idea what the issue may be with the script? Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 01:37 AM
Let give GlideDateTime and GlideTime a try. It will give you the amount of time that daylight saving time is offset.
Sample below. The Eastern DST in 2024 starts from March 10, 2024 at 2 a.m. local time.
So in your script, the day and time validation part could be adjusted as following.
var gt = new GlideTime();
var gdt = new GlideDateTime();
var currentHour = gt.getHourLocalTime();
var currentDay = gdt.getDayOfWeekLocalTime();
if (currentHour >= 8 && currentHour < 16 && currentDay >= 2 && currentDay <= 6) {
current.assignment_group = '7eb27171c3e41e5404362af0e00131f2'; // ATM Settlement
} else {
current.assignment_group = '64d6e252db83d3004c7b55384b9619d5'; // ATM Services
}
Let me know if it works for you.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 03:31 PM
Hey there,
Check out this thread, it seems to have the same problem you are trying to solve: https://www.servicenow.com/community/itsm-forum/auto-assign-assignment-group-based-on-time-of-day-sc...
You'll just need to create your own schedule and be sure to update that schedule name in the script on 2nd line of the method ifScript.
~Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 01:37 AM
Let give GlideDateTime and GlideTime a try. It will give you the amount of time that daylight saving time is offset.
Sample below. The Eastern DST in 2024 starts from March 10, 2024 at 2 a.m. local time.
So in your script, the day and time validation part could be adjusted as following.
var gt = new GlideTime();
var gdt = new GlideDateTime();
var currentHour = gt.getHourLocalTime();
var currentDay = gdt.getDayOfWeekLocalTime();
if (currentHour >= 8 && currentHour < 16 && currentDay >= 2 && currentDay <= 6) {
current.assignment_group = '7eb27171c3e41e5404362af0e00131f2'; // ATM Settlement
} else {
current.assignment_group = '64d6e252db83d3004c7b55384b9619d5'; // ATM Services
}
Let me know if it works for you.
Cheers,
Tai Vu