Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set date on custom field

Erik Ekengren
Contributor
March 23, 2020

Hi!

I have a custom field (Date Time Picker) on a create issue screen. The Jira date time picker has the format yyyy-MM-dd HH:mm. On the create issue screen I would like to pre-populate with todays date and always HH:mm 08:00, for example todays date would be 2020-03-23 08:00 even though I register the ticket at 13:00, and the next day it would be 2020-03-24 08:00 and so on.

 

I have Scriptunner as a plugin so I believe this could be achived with a behaviour, however I don´t know how to write this groovy-script. Could someone point me in the right direction?

1 answer

1 accepted

0 votes
Answer accepted
Erik Ekengren
Contributor
March 26, 2020

For anyone struggling with the same question as I had this was the solution for me:

 

import java.sql.Timestamp
import java.util.concurrent.TimeUnit

def date = getFieldById("create-date")
def start = getFieldById("customfield_13600")

def defaultValue = new Date(new Date().time + TimeUnit.DAYS.toMillis(0)).format("yyyy-MM-dd 08:00")


if (! start.getValue()) {
start.setFormValue(defaultValue)
}

Suggest an answer

Log in or Sign up to answer