I'm trying to write a scriptrunner post function script to transition a linked issue in another project. I've used pieces from the Auto Close Subtasks and All Depending Issues Resolved examples to come up with my code.
When the post function runs, the user sees an error "Property 'destIssue' not found" in the transition screen and can't proceed. Had a look at the API docs and I seem to be doing everything correctly.
This is my first groovy script, so I'm sure I've done something wrong, but don't know where.
I was also wondering about the ScriptRunner's example code use of directly accessing values such as "issue.id" and "it.statusObject.name" instead of using accessor methods to get these values. Is this proper or just old styling?
Running JIRA 6.3.13.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueService = ComponentAccessor.getIssueService()
def linkType = ["escalated from"]
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
if (linkType.contains(link.issueLinkType.name)) {
def destIssue = link.getDestinationObject()
def destStatusObject = destIssue.getStatusObject()
if (destStatusObject.name == "Installing") {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setComment("Camera has been installed. Signs are needed before camera can be activated.")
setSkipScreenCheck(true)
}
def validationResult = issueService.validateTransition(user, destIssue.id, 41, issueInputParameters)
if (validationResult.isValid()) {
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}")
}
}
}
}