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

Script to Update Custom field with last date.

I Have a EPIC and three stories in it.

 

Need to use a post-function or listner Script to update the Date field ( DUE DATE) of the EPIC.

 

1. The script needs to check DUE DATE field of the three stories.

2. The farthest date in the ( DUE DATE ) should be updated DUE DATE field of EPIC.

 

Any suggestions for the same. 

1 answer

1 accepted

1 vote
Answer accepted

Hi siva,

What about to place an Scripted field instead at the Epic level?

 

You must tune this code to fit your needs

 

/*
* @Author: Jack Nolddor [Sweet Bananas] <support@sweetbananas.es>
* @Date: 06-Oct-2019
*
* @Description:
* Field that returns the further date from the configured linked issues
* You must to use Date Time Template
* You must to use Date Time Range picker Searcher
*
* See the link below for further details:
* https://community.atlassian.com/t5/Jira-questions/Script-to-Update-Custom-field-with-last-date/qaq-p/1196044
*/

import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.jira.issue.link.IssueLinkManager


def log = Logger.getLogger("com.nolddor")
log.setLevel(Level.DEBUG)

@PluginModule
IssueLinkManager issueLinkManager


//--------------------------------------------------------------
// You must change the following variables as your needs
//--------------------------------------------------------------
def sourceIssueTypes = ["Story"]
def excludeResolvedIssues = true
//--------------------------------------------------------------

// Look for all linked issues
def linkedIssues = issueLinkManager.getOutwardLinks(issue.id)*.destinationObject
// Remove undesired issue types
linkedIssues = linkedIssues.findAll{it -> sourceIssueTypes.contains(it.issueType.name)}
// Remove resolved issues, if applicable
if(excludeResolvedIssues)
{
linkedIssues = linkedIssues.findAll{!it.resolutionDate}
}
// Sort remaining linked issues by dueDate
linkedIssues.sort{it.dueDate}
// Return the further dueDate
if(linkedIssues)
{
return linkedIssues.last().dueDate
}

 

 

 

Let us know if the provided code snippet solves your problem,

Regards

@Jack Nolddor -Sweet Bananas- 

 

Thanks, this does the job.

 

can you add a script line to check issues with are not closed or completed.

CLOSED issues should not be considered.

I've improved the given script to also remove the resolved issues ;) Enjoy!

 

Did my answer solve your problem?

If so, consider to mark the proposed solution as an 'Accepted answer'. This will help other people with the same or a quite similar problem to find a solution in a easy and faster way.
Otherwise, if you solved the problem in a way that hasn't been suggested yet in this thread, please I encourage you to reply your original message to tell us what was the final solution for the problem, you can also mark your own reply as an 'Accepted answer'.

In addition, by doing this the post will automatically gain the "Solved:" prefix in search results to indicate other people that no further support is needed.

Kind Regards.

@Jack Nolddor -Sweet Bananas- 

THANKS, JACK,, that was quick.


I'm off work now, compiled against a ticket shows the right data.

 

WORKS..!!

I might need another script from you, will update the details ( similar to the present one)

few changes would do.

Glad to help, just summon me on the new thread if needed ;)

Happy coding!

@Jack Nolddor -Sweet Bananas- 

 

You must to use Date Time Template
* You must to use Date Time Range picker Searcher

i have selected Date Time Template.

 

But When Date Time range picker serarcher im not able to create issues. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

303 views 1 3
Join discussion

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