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

Scriptrunner listener to update custom date/time field

Hi All,

I need to write a listener that will add current timestamp to a custom date/time fields when another field is updated.

For example, if custom checkbox "Approved" is set, the listener detects this change and will timestamp the custom date/time field "Approved Date".

I had intended to simply do this through the JIRA Suites Utility plugin on a workflow transition, but the requirements have changed and this needs to be done on an "Edit" and hence needs to be detected and updated by a custom listener.

 Can @Thanos Batagiannis [Adaptavist] , @Jamie Echlin [Adaptavist] or some of the other Adaptavist guys please help me out here?

Any help is much appreciated.




1 answer

1 accepted

Hi Conor,

Try something like 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

import java.sql.Timestamp

Issue issue = issue
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "CheckBox A"}
if (change) {
    def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approved DateTime")
    def changeHolder = new DefaultIssueChangeHolder()
    def now = new Timestamp(new Date().getTime())
    cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), now),changeHolder)

Please let me know if this does the trick.

regards, Thanos

Hi @Thanos Batagiannis [Adaptavist], thank you for that great assistance. I was about to accept the answer smile until I hit a real roadblock - the listener isn't firing when I try to bulk transition issues!

There will be occasions when I want to bulk edit closed issues to update these fields, restricting it to the Product Owner role.

To do this I intended to add a transition to loop from Closed to Closed and call it "Product Owner Update". This would present the screen to allow for the fields to be updated. All of this works when working on a single issue, but when I try to bulk transition (update) a set of Closed issues the transition does not fire sad 





Hi Conor, 

How do you bulk update the issues ?

I'm trying to bulk update Closed issues in this scenario, so I'm actually bulk transitioning (Closed to Closed) via a transition that is restricted to a limited set of users


image2017-2-15 15:10:19.png


The transition fires the "Issue Updated" event which the listener picks up. Works on single issues, but doesn't fire or isn't detected when doing bulk transitions

these status properties are my saviour, and I can now edit closed (bulk edit even) and do not need to do it via bulk transitions


image2017-2-15 17:0:24.png



Can I perform the operation with a text field instead of a Checkbox?

Can any one guide me to any resources or the code?

any help is appreciated.

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