We can create a Script Listener triggered at UPDATE ISSUE event.

Captura de pantalla 2017-12-01 a las 18.02.58

Just copy/paste the code and configure the name of the Type of Link.


String tipolink = "Sync"; //Name of the type of link

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.status.Status
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.opensymphony.workflow.loader.ActionDescriptor
import com.opensymphony.workflow.loader.StepDescriptor
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager
import com.atlassian.jira.issue.changehistory.ChangeHistoryItem
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.util.ErrorCollection
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.*
import com.atlassian.jira.issue.link.IssueLink;
import org.apache.log4j.Category

ApplicationUser user = event.getUser()
Issue issue = event.getIssue()
Status status = issue.getStatus()

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug "debug statements"

Long Estimate = issue.getOriginalEstimate();
log.debug "Original Estimate:"+ Estimate;
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
List<IssueLink> allInIssueLink = issueLinkManager.getInwardLinks(issue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink) inIterator.next();
def linkedIssue = issueLink.getSourceObject();
log.debug "LinkTypeId:" + issueLink.getIssueLinkType().getName() + " linked: ${linkedIssue.getId()}, ${linkedIssue.getKey()}. DETECTED:" + linkedIssue.getStatusObject().getName();
if (issueLink.getIssueLinkType().getName().equals(tipolink) ) {
log.debug "linked Content: ${linkedIssue.getId()}, ${linkedIssue.getKey()}."
def linked = (MutableIssue) linkedIssue;
linked.setOriginalEstimate(Estimate);
linked.store();
log.debug "Original Estimate copied";
}
}

Don’t forgive to set in the Screens the System field “Time Tracking” to set the Original Estimate!

Posted by:.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s