Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Populate Assignent group based on ticket created time

VenkateshA42034
Tera Contributor

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.

2 REPLIES 2

maliksneha9
Mega Sage

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);

 

 

Tanushree Maiti
Tera Sage

Hi @VenkateshA42034 

 

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.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: