Populate Assignent group based on ticket created time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I need to fill the assignment group based on the invoice created time using flow designer in servicenow.
If the invoice is created between 3 pm and 6.59 am IST it should assign to Evening shift group or else it should assign to morning shift group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
To achieve this in ServiceNow Flow Designer, the most reliable approach is to use a Custom Script Action. Since standard Flow Designer condition builders don't handle specific time-of-day logic across day boundaries, a small script snippet is the most efficient way to handle it.
Add a "Script" step to your flow to determine the shift. This avoids complex "If/Else" nesting.
(function execute(inputs, outputs) {
var gdt = new GlideDateTime(inputs.created_at);
// Convert UTC to IST (Add 5 hours and 30 mins)
var tz = Packages.java.util.TimeZone.getTimeZone("Asia/Kolkata");
gdt.setTZ(tz);
// Get the hour of the day in 24-hour format (0-23)
var hour = parseInt(gdt.getTime().getByFormat('HH'));
// Logic: 3 PM (15:00) to 6:59 AM (06:00)
// This means if hour >= 15 OR hour <= 6, it is Evening Shift.
if (hour >= 15 || hour <= 6) {
outputs.shift = "Evening Shift Group";
} else {
outputs.shift = "Morning Shift Group";
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Use a Flow Logic IF with a script to check
if the sys_created_on falls between 15:00:00 and 06:59:59.
Assign to "Evening Shift" if true,
else "Morning Shift" using Update Record.
