Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JSON date and time string to DateTime with smart values?

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")}}

 

1 answer

1 accepted

0 votes
Answer accepted
Nir Haimov Community Leader Apr 07, 2021

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.

Nir Haimov Community Leader Apr 08, 2021

@Sam Lander can you send screenshot of the automation, so we can see exactly how look what you wrote?

Thanks for pointing out the "Log Action", that made my life eeasier.

Screenshot:

grab.png

Nir Haimov Community Leader Apr 08, 2021

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

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Confluence

⚡️NEW Group for Confluence Cloud Admins

Calling all Confluence Cloud Admins!  We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...

117 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you