Howdy,
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?