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

Custom date field to auto-populate with current date?

I have a custom field for our review board that is a single select drop down menu with the options of "yes" or "no". If "no" is selected, nothing happens. However, if "yes" is chosen, we have a Reviewed Date field that appears with using behaviors on scriptrunner (we need this because you can't search on when custom fields were changed).

For that date selection field, I'd like to auto-populate with the current date when "yes" is selected. Any ideas on how to achieve this? 

Thanks in advance!

1 answer

1 accepted

Assuming Reviewed Date is a Date Picker field, you can attach following Behaviour snippet to the field:

if (getFieldByName("yourSelectList").getValue() == "yes") {
} else {

This will set the current date on the field when option "yes" is selected and clear the value when option "no" is selected.

Unfortunately, this does not work. When I select "yes" in our drop down, it will not allow me to add a date and it doesn't add a date on its own either.

1. Did you change "yourSelectList" to the name of your select list?
2. Is your option value name "yes" or "Yes"?
3. What do you mean by it will not allow you to add a date?
4. Is Reviewed Date field a Date Picker field?

Can you post your original Behaviour script in text on how you make Reviewed Date field appears as well as the screenshots of the behaviour configurations?

Above snippet is for you to incorporate into the original Behaviour script.

The important part is how to set current date on a Date Picker field:


1. Yes, I changed the "yourSelectList" to the name of my field.

2/3. I updated the selection to match my list, it is "Yes", not "yes" so that was why it wouldn't allow me to add a date I'm assuming. So that answers question 3.

4. Yes, Review Date is a Date Picker field.


It's still not populating a date even though I've made updates to the code. I unfortunately cannot post screenshots as my environment is not unclassified. 


def ReviewedDate = getFieldByName("Reviewed Date")

def Reviewed = getFieldById(getFieldChanged())

def selectedOption = Reviewed.getValue() as String

def isYesSelected = selectedOption == "Yes"


def selectlistselection = getFieldByName("Reviewed").getValue()

def reviewedDate = getFieldByName("Reviewed Date")

if (selectlistselection == "Yes") {



else {reviewedDate.setRequired(false) 


Hi @Laci 

This should work (I also make the script more consistent and clearer):

def ReviewedDate = getFieldByName("Reviewed Date")
def Reviewed = getFieldById(getFieldChanged())
if (Reviewed.getValue() == "Yes") {
} else {

Please note that if "No" is selected the date is cleared. If this is not your intention you can delete "ReviewedDate.setFormValue(null)".

Hope this helps!


@Max Lim _Adaptavist_ Thanks so much! This appears to be working! I appreciate your help!

@Laci I'm trying to do something very similar.  I've been trying to do it in a Listener, but perhaps the Behavior is appropriate too.  Would you mind posting your code here?

@Kevin Comco Try the script that @Max Lim _Adaptavist_ wrote above. That's what I'm using. You'll just need to update the field names.

@Laci thanks for the reply.  I'm having trouble getting the right classes for a couple of the methods (e.g. setFormValue) and was hoping to see your imports, full context, etc...

Quick question, are you able to JQL query on the dates you end up setting?  I'm able to get my date picker to visually look like it's all good, but JQL fails to find anything because it thinks the field is EMPTY.

Suggest an answer

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

Jira issue check and more advanced commit verifications for Bitbucket DC

Pre-receive hooks that verify the Git commit message, the modified files, and implement similar code change controls used to be requirements of large enterprises working in regulated industries only....

31 views 0 2
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