Assignment rule scripting based on Central time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
- All incidents and requests for type "corporate" received between 6:00 AM and 5:00 PM Central Time should be assigned to: Group1
- Any requests outside of this time window should be assigned to: Group2
I created two assignemnt groups. But the incident raised through record producer is getting assigned to Group 1 only even though I am raising the request on outside business hours. Can someone help me with the exact script?
I used this script, but it is not giving correct result:
(function() {
var nowCT = new GlideDateTime();
nowCT.setTZ('America/Chicago');
var hour = parseInt(nowCT.getHourLocal());
return (hour < 6 || hour > 17);
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
It is still not working. It is getting assigned to Group 1. Even though currently it is outside business hours hence it should be assigned to group 2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
run this script in background script and share the results
are you using schedule logic or the 2nd script
var strConvertedDateTime = new GlideScheduleDateTime(new GlideDateTime()).convertTimeZone("UTC", "CET");
var gdtConvertedDateTime = new GlideDateTime(strConvertedDateTime);
var hours = gdtConvertedDateTime.toString().split(' ')[1].split(":")[0];
if (hours >= 6 && hours <= 17) {
// within business hours
gs.info('within business hours');
} else {
gs.info('outside business hours');
}
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
The background script is saying within business hour, but it is still 20 minutes left for 6am in CET time.
I am using 2nd script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
got it, you want central time, I thought CET which is Europe
update script as this -> use CST instead of CET
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
