Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Auto populate custom date field on change of status

Hi Team,

My requirement is date field should be added into a custom field automatically, when the XXX issue type state is moved to "xxxxxx". Using server version and also using script runner for jira plugin.




1 answer

0 votes
Andy Rusnak Atlassian Team May 10, 2022

Hi Kammili, 

There are a few ways that I believe you can accomplish this.  But just to make sure I understand what you are trying to do you want to accomplish the following: 

  1. Issue is status A and issue has a custom date field. 
  2. User transitions the issue to status B and during the transition a custom date field is automatically set to a value

Is that correct? 

If my understanding is correct and you want to use ScriptRunner, you should be able to accomplish this using a Workflow Transition Post Function and the ScriptRunner Custom script post-function.  I think you can do the following: 

  1. Edit the Workflow in question: Jira > Gear Icon > Issues > Workflows > ( Select Workflow ) > Edit. 
  2. Select the transition you wish this to happen on and choose Post Functions
  3. Add Post Function and select the Custom script post-function [ScriptRunner]
  4. Set up your ScriptRunner script that will set your custom date field to the value you need.  Below is a very simple example I set up to set the field 'Test Custom Date' to today's date: 


import com.atlassian.jira.component.ComponentAccessor

// Name of the custom field to change

final customFieldName = "Test Custom Date"

// New value for that field

final newValue = new Date();


def customFieldManager = ComponentAccessor.customFieldManager

def customField = customFieldManager.getCustomFieldObjects(issue).find { == customFieldName }

assert customField: "Could not find custom field with name $customFieldName"

issue.setCustomFieldValue(customField, newValue.toTimestamp())

This was adopted from Custom Field Post Function script in the Adaptavist library to use a date rather than a text field.  

Once you have set this up you should be able to publish your Workflow and the custom date field will be set when this post function runs upon transition.  

Of course whenever making these types of changes it would be strongly recommended to test these types of changes out in a non-production workflow first.  This is very simplified example I tested, so there certainly could be additional complications in your business process that need fine tuning. 

But this quick example seemed to accomplish what I believe you are attempting to do in my environment.  

Please let me know if this works for you or if you have any questions related to this and I would be happy to help out further.  




Suggest an answer

Log in or Sign up to answer

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