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.
Regards,
Conor
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 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Conor,
How do you bulk update the issues ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.