Autopoulate assignement group based on Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 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 want to autopopulate the group as soon as I am changing the type in the incident while raising or updating the request manually.
- When transferring a ticket to a different department, the ticket should not be assigned to an individual user within that department. It should remain assigned to the assignment group only. And one group members cannot edit the assigned to feild.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Sohini Kar ,
We can do this via before insert/update business rule with script. Play around GlideDateTime to get hours of your requirement.
var now = new GlideDateTime();
var hour = parseInt(now.getHourLocalTime());
if (current.type == 'corporate') {
if (hour >= 6 && hour < 17) {
current.assignment_group = 'GROUP1_SYS_ID';
} else {
current.assignment_group = 'GROUP2_SYS_ID';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Sohini Kar
You can try with this sample steps and code.
Create a Schedule(For Timezone CST):
Navigate to System Scheduler > Schedules > Schedules.
Create a new schedule (e.g., "Corporate Business Hours - CST").
Set the Time Zone to US/Central.
Define the working days and hours (e.g., Mon-Fri, 8 AM - 5 PM) and add child schedules for holidays.
Create a BR (Before,Insert):
Create a new Business Rule on the incident ( if you need for sc_task, create separate BR) .
When: Before & Insert.
Condition: Type is Corporate (provide correct condition).
Script: Use the GlideSchedule API to check if the current time (GlideDateTime) falls within your created schedule
var schdSysId = '<your_schedule_sys_id>';
var sched = new GlideSchedule(schdSysId);
var now = new GlideDateTime();
if (sched.isInSchedule(now)) {
current.assignment_group.setDisplayValue('Corporate Support Team');
} else { current.assignment_group.setDisplayValue('<other group>');
}
Also you can refer Similar post :https://www.servicenow.com/community/developer-forum/how-to-use-assignment-rules-with-schedules/m-p/....
