I'm using Jira automation.
The incoming JSON on a webhook has "2021-11-23 23:45" in it.
I'd like to splat it into a customfield as a DateTime
So far, my attempts have yielded either a action failure or no data.
Best-guess I have is this, but that results in an empty field...
{{webhookData."Date and Time of Incident".toDateTime("yyyy-MM-dd HH:mm")}}
Hi @Sam Lander
Try ".toDateTime.as("yyyy-MM-dd HH:mm")
Try first to print it to the automation log, see if you get the result you want, then try to set it to a field.
Note that in order to set it to a field the format must be exactly as your dateTime customfields look like, make sure if you need use "-" or "/"
Thanks for the suggestion @Nir Haimov
I get
Error creating issueError parsing time: 2021-04-12 14:23.toDateTime.as("yyyy-MM-dd HH:mm")}} (customfield_10032)
or
Error creating issueError parsing time: 2021-04-12 14:23.toDateTime("yyyy-MM-dd HH:mm")}} (customfield_10032)
using either method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Sam Lander can you send screenshot of the automation, so we can see exactly how look what you wrote?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for pointing out the "Log Action", that made my life eeasier.
Screenshot:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem :)
According to the documentations,
The following functions can be used to convert a date to a date with a time component:
{{now.toStartOfDay}}
{{now.toCurrentTime}}
{{now.toDateTimeAtStartOfDay}}
{{now.toDateTimeAtStartOfDay(timezone)}}
{{now.toDateTimeAtCurrentTime}}
{{now.toDateTimeAtCurrentTime(timezone)}}
Please try them out let me know if one of them works for you, if not, send screenshot with them too :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think that this is the only possible answer. It is not so clean, because it implies stripping out the time with string ops, then adding it back into the DateTime created by blah.toDateTimeAtStartOfDay - I was hoping for something cleaner ....
I have implemented a workaround (a text field called "user-reported Time of Incident") instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to show how you exactly did this?
I want almost exactly the same as you :-)
Regards,
Nico
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.