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

Your Points Tracker
  • 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
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?
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

How to store datetime via scriptrunner postfunction in JIRA Cloud



Using JIRA Cloud, I'm trying to store the current date in a datetime custom field. This has to happen after a transition, if the field is not empty. Solutions I've been exploring:

1. simply add a post-function custom field update, use the %%CURRENT_DATETIME%% , but this does overwrite existing values

2. use the approach above, create two transitions and in the conditions, use a scripted condititon to check if the field is empty, and allow only the transition that is right for the situtation - ugly, as there are a bunch of conditions already and there will be two transitions (this is my backup plan)

3. use Automation - unfortunately there is no conditions that can check datetime customfields

4. write a post-function script using scriptrunner and handle the null check with code


I'm at nr. 4, all good, but can't store the time. I'm lost with the dateformat.  

def today = new Date()
def formattedToday = today.format('YYYY-MM-dd hh:mm:ss')

This doesn't work, I get this error:

2021-03-12 15:38:36.933 WARN - PUT request to /rest/api/2/issue/RM-18 returned an error code: status: 400 - Bad Request
body: {"errorMessages":[],"errors":{"customfield_10038":"Error parsing time: 2021-03-12 03:38:36"}}


How should the format string look like? 

2 answers

1 accepted

2 votes
Answer accepted

I guess I found the correct format, now it seems to be working:

def today = new Date()
formattedToday = today.format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")

This is going to end up in ISO 8601 format that is consumed by JIRA correctly. 

Found it here: Parse date to “yyyy-MM-dd'T'00:00:00” using Groovy  

Hi @Laci Kremer 

Thank you for your question.

We have an example in our documentation here to refer to as a guide. This documentation, it will show you how to set a date field and the format date needs to be in.

I hope this will help.

Kind Regards


Hi Kate,


Thank you for your response. The linked doc and examples are great, but only shows the date format, not the datetimeThe field I'm working with is a DateTime picker. 

Do you have examples for storing datetime?


(I just tried storing the value what I get from new Date(), but that is not being parsed either:

def today = new Date()

.header("Content-Type", "application/json")
(myCustomField): today as String

 this results in:

2021-03-16 13:45:33.722 WARN - PUT request to /rest/api/2/issue/RM-31 returned an error code: status: 400 - Bad Request
body: {"errorMessages":[],"errors":{"customfield_10038":"Error parsing time: Tue Mar 16 13:45:33 UTC 2021"}}


Please advise, how to store time in a customfield with ScriptRunner!

Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

354 views 19 20
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