Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner listener to update custom date field based on "End Date" of tasks linked to epic issue

Paul Kelly August 23, 2021

How would I create a listener on a custom field ( "Project End Date" ) that would exist only on epic issues such that the field would be updated with the most distant future date value of any linked issues' field value for "End Date"?

 

My objective is to:

1. have a listener on the field "End Date" of each issue (not epics)

2. When "End Date" is changed then update the custom field value "Projected End Date" on any linked epic issues if the value of "End Date" is a more distant future date than what is already populated in "Projected End Date"?

 

 

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

Any help is much appreciated!

2 answers

1 vote
Martin Bayer [MoroSystems, s.r.o.]
Community Champion
August 23, 2021

Hi @Paul Kelly , you will need to check and use the following logic

  1. need to created listener for IssueUpdated event
  2. read all the changed items for the raised event
    1. event should be of type IssueChangedEvent (https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/event/issue/IssueChangedEvent.html)
    2. it has methods
      1. getChangeItems()
      2. getChangeItemForField
      3. you can use it read changed fields
      4. if it contains End Date field, you can read its old and new value (https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/history/ChangeItemBean.html)

I hope it will help but let me know if you need more help

0 votes
Daniel Ebers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2021

Hi @Paul Kelly

in case the Listener is not a hard requirement I can come up with a solution we used in the past based on

To make sure it still works I tried it right now and it works perfectly - following the steps mentioned in the link you can get a solution.

Agreeing with Martin his approach is the better one if:
1.) you want to learn and understand the mechanism ... and/or ...
2.) the listener is a hard requirement

Regards,
Daniel

Martin Bayer [MoroSystems, s.r.o.]
Community Champion
August 28, 2021

Hi, yeah, Scripted field is definitelly a good solution too :)

Suggest an answer

Log in or Sign up to answer