Help with Automation Smart values please?
I have created an automation that calculates a due date/time field based on when the ticket is lodged. This smart value works perfectly:
{{issue.customfield_1003.plusBusinessDays(5)}}
The team have now asked if a certain field is selected, can the due date auto calculate to 5pm that same day (aka end of that business day). Does anyone know a smart value that would allow for this?
Hi @Kate -
It's kind of a weird syntax, but playing around with "To date with time conversion" I came up with this:
{{now.withHour(17).withMinute(0).withSecond(0)}}
Which returned:
2023-07-04T17:00:00.0+0000
Which hrm, that's 5PM tomorrow, since it's not my time zone.
So I then added my time zone:
{{now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)}}
There we go:
2023-07-03T17:00:00.9-0700
So yeah, that ought to work.
Caveat, it's 7:54PM in my time zone, so things might get a little trickier if say, at 5:01PM, you wanted the date to be the next business day at 5PM.
You could probably do some conditional logic and use the isAfter function. Maybe in conjunction with toDateTimeAtStartOfDay.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why oh why doesn't Automation have an ELSE operator? I ended up having to have back-to-back IFs to get this to work:
{{#if(now.convertToTimeZone("America/Los_Angeles").isBefore(now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)))}}{{now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)}}{{/}}{{#if(now.convertToTimeZone("America/Los_Angeles").isAfter(now.convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)))}}{{now.plusDays(1).convertToTimeZone("America/Los_Angeles").withHour(17).withMinute(0).withSecond(0)}}{{/}}
Caveat: If somebody somehow sets that field at EXACTLY 17:00:00.0... I'm not sure what will happen. :-}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Darryl! I tried using this option:
{{now.withHour(17).withMinute(0).withSecond(0)}}
and its defaulting for the next day for me as well! I'm located in NZ, so I don't think it's a timezone issue, but it's definitely a head scratcher. This is a great starting point though!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kate - I would try this to see if it gives you what you're expecting:
{{now.convertToTimeZone("Pacific/Auckland").withHour(17).withMinute(0).withSecond(0)}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.