Hello,
I'm want to use a post-function with ScriptRunner to update the status and add a comment into the linked issue that is in an other projet.
So I have issue SUP-100 that was cloned (with exocet) into projet DEV and are linked together. my SUP task is in pending for the work to be completed in DEV. When they complete this issue I want it to trigger a post function to transistion the linked task into open status.
I've looked into other ways and I found this previous post here.
I've took the script and change what I really needed it to do but when it run (no error) nothing is happening to my other issue.
Here my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueService = ComponentAccessor.getIssueService()
def linkType = ["Escalated"]
// 6.x validateTransition wants a User, so we have to use getDirectoryUser()
// 7.x validateTransition wants an ApplicationUser, so remove the .getDirectoryUser() after we upgrade
def user = ComponentAccessor.getUserManager().getUserByName("jirabot").getDirectoryUser()
def linkMgr = ComponentAccessor.getIssueLinkManager()
// Look through the outward links
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
def destIssue = link.getDestinationObject()
// Prepare our input for the transition
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setStatusID("Open")
setComment("Linked task was completed, hence status changed to open")
setSkipScreenCheck(true)
}
// Validate transitioning the linked issue to "Signs Needed"
def validationResult = issueService.validateTransition(user, destIssue.id, 41, issueInputParameters)
if (validationResult.isValid()) {
// Perform the transition
def issueResult = issueService.transition(user, validationResult)
if (! issueResult.isValid()) {
log.warn("Failed to transition task ${destIssue.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.warn("Could not transition task ${destIssue.key}, errors: ${validationResult.errorCollection}")
}
}
I'm open to use other methode if it get the status updated so I can get this automated.
I'm not an expert in javascript but I'm trying to learn more about it so I can automate more within our Jira projet.
Thank you in advance
My current version of Jira is 7.6.1