Hi everyone,
After doing some research online, and editing/adding some script I came up with a postfunction that is suppose to transition a linked issue in another project.
When the source issue gets moved from populate to review, I want the other issue(linked issue) within another project to get moved from Display to Not Display. This post funtion lies in the source issue transition. Can somone help me and let me know what I need to change to make the issues transition properly. My script and the logs are displayed below:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
def issueService = ComponentAccessor.getIssueService()
def linkType = ["relates to"]
// 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.getJiraAuthenticationContext().getLoggedInUser()
def linkMgr = ComponentAccessor.getIssueLinkManager()
// Look through the outward links
log.debug("commence for loop")
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
log.debug("entered for loop")
def destIssue = link.getDestinationObject()
// Does the name of the link match "relates to" ?
if (linkType.contains(link.issueLinkType.name)) {
log.debug("relates to is the link type")
def destStatusObject = destIssue.getStatus()
// Is the status of the linked issue "Display" ?
if (destStatusObject.name == "Display") {
// Prepare our input for the transition
log.debug("Status == Display")
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setComment("Cancelled Vacation Request by HR")
setSkipScreenCheck(true)
}
// Validate transitioning the linked issue to "Signs Needed"
def validationResult = issueService.validateTransition(user, destIssue.id, 61, issueInputParameters)
if (validationResult.isValid()) {
log.debug("Validation Result is valid")
// Perform the transition
def issueResult = issueService.transition(user, validationResult)
if (! issueResult.isValid()) {
log.debug("Failed to transition task ${destIssue.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.debug("Could not transition task ${destIssue.key}, errors: ${validationResult.errorCollection}")
}
} else {
log.debug("Skipping link: ${link.issueLinkType.name} ${destIssue.key} ${destStatusObject.name} (wrong status)")
}
} else {
log.debug("Skipping link: ${link.issueLinkType.name} ${destIssue.key} (wrong type)")
}
}
2017-07-10 14:01:48,811 DEBUG [acme.CreateSubtask]: commence for loop
2017-07-10 14:01:48,811 DEBUG [acme.CreateSubtask]: entered for loop
2017-07-10 14:01:48,812 DEBUG [acme.CreateSubtask]: relates to is the link type
2017-07-10 14:01:48,812 DEBUG [acme.CreateSubtask]: Status == Display
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]: ContactSelectCF getValueFromCustomFieldParams
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]: ContactSelectCF getValueFromCustomFieldParams singleParam 11417
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]: ContactSelectCF getValueFromCustomFieldParams option 11417 : Not defined
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]: ContactSelectCF validateFromParams crm org option null for OAG-39
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]: ContactSelectCF :: store put Not defined : 19342_customfield_11711
I figured out the issue and my solution can be seen on this URL:
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.