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

Tracking due date history in a text field using behaviors in Scriptrunner

I am trying to capture the history of due dates in a custom text field, 'Deadline Extension History'. I have set up a ScriptRunner (v 6.24.0) behavior to make the change each time the due date is changed by a user.


import java.text.SimpleDateFormat

SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");

def DEH = getFieldByName("Deadline Extension History")
def dueDateField = getFieldById(getFieldChanged()) // Due date has changed
def dueDate = dueDateField.getValue() as Date

// Get the current value of the Deadline Extension History
def selectedOption = DEH.getValue() as String
def valueSet = selectedOption + '\n' + sdf.format(dueDate)


When I make a change to the date, instead of concatenating a single date to the Deadline Extension History it adds several dates:



When I modiry the valueSet to either 'selectedOption' or to 'sdf.format(dueDate)', the Deadline Extension History will take on only the value of selectedOption or sdf.format(dueDate), respectively.

Is there a there a better way to set up the behavior to get the expected value? I am able to make this happen on transition, but would prefer to avoid that path.

1 answer

1 accepted

0 votes
Answer accepted

Hello @Cory Strope 

Rather than storing every single change in a text field, it would be better to use a read-only/calculated custom field which will directly provide historical dates for duedate field. 

Let me try with a code snippet below. dueDateChanges variable will hold every date values

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.changeHistoryManager
def issueManager = ComponentAccessor.getIssueManager()

def dueDateChanges = []
changeHistoryManager.getChangeItemsForField (issue, "duedate").each {
if (null != it.from) dueDateChanges.add(it.from)
if (null != issue.dueDate) dueDateChanges.add (issue.dueDate)

If dueDate changed it will add the "from value" of the change item, then it adds the current value at the end.

You might do the correct date conversions but this code will do your trick after changing a couple of lines for your needs.

I hope it helps


After returning the array, it worked perfect.


Perfect! I'm glad that it worked.

Like Cory Strope likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Introducing External Collaboration for Confluence

We’re excited to introduce external collaboration for Confluence, now available in early access. It is available to preview for Confluence Cloud Premium and Enterprise customers. (If you're not on ...

239 views 0 8
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