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 set a date field to current date using behaviors?


Since the "default current date" option in Jira defaults to the issue created date, I'm trying to use behaviors to set the field to current date.

I'm using the below date to achieve this. The script is setting the date as expected but editing is not working i.e the field doesn't let the user save a new date, even if a new date is selected, the current date is set back again.

import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager;
import java.lang.Object
import java.util.Date
import java.sql.Timestamp

IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class);
FormField formField = getFieldById("customfield_10111");

def date = new Date()
String newDate = date.format("dd/MMM/yy")


Please advice.


1 answer

You can try this something like


import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
import java.util.Date
import java.util.TimeZone

def cfHot = getFieldByName("HOT")
def cfHOTReason = getFieldByName("HOT Reason")
def cfHOTDateOn = getFieldByName("Became Hot On")


if (cfHot.value == null || cfHot.value == 'No' ){



if (cfHot.value == 'Yes' ){

String DATE_FORMAT = "dd/MMM/yy h:mm a"
SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT)
String CurrentDate = new java.sql.Timestamp(new Date().getTime()).format("dd/MMM/yy h:mm a")
Date date = formatter.parse(CurrentDate)
//log.error 'CurrentDate: ' + CurrentDate

SimpleDateFormat sdfAmerica = new SimpleDateFormat(DATE_FORMAT)
TimeZone tzInAmerica = TimeZone.getTimeZone("America/Los_Angeles")

String sDateInAmerica = sdfAmerica.format(date)
Date dateInAmerica = formatter.parse(sDateInAmerica)

//log.error 'INAMERICA000: ' + formatter.format(dateInAmerica)


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

181 views 2 1
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