Hello i did the same code in a post function , an error always appear , please can somone help me !!!
My code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueService = ComponentAccessor.getIssueService()
def linkType = ["Cloners"]
// 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().getUser().getDirectoryUser()
def linkMgr = ComponentAccessor.getIssueLinkManager()
// Look through the outward links
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
def destIssue = link.getDestinationObject()
// Does the name of the link match "Cloner" ?
if (linkType.contains(link.issueLinkType.name)) {
def destStatusObject = destIssue.getStatusObject()
// Is the status of the linked issue "En attente niveau 2" ?
if (destStatusObject.name == "En attente niveau 2") {
// Prepare our input for the transition
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setComment("Camera has been installed. Signs are needed before camera can be activated.")
setSkipScreenCheck(true)
}
// return destStatusObject.name
//return destIssue.id
// return user
// Validate transitioning the linked issue to "Signs Needed"
def validationResult = issueService.validateTransition(user, destIssue.id, 31, issueInputParameters)
return validationResult
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}")
}
} else {
log.warn("Skipping link: ${link.issueLinkType.name} ${destIssue.key} ${destStatusObject.name} (wrong status)")
}
} else {
log.warn("Skipping link: ${link.issueLinkType.name} ${destIssue.key} (wrong type)")
}
}
error:
V2018-10-27 20:13:12,919 ERROR [runner.ScriptFieldPreviewRunner]: ************************************************************************************* 2018-10-27 20:13:12,919 ERROR [runner.ScriptFieldPreviewRunner]: Script field preview failed for field that has not yet been created groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.bc.issue.DefaultIssueService.validateTransition() is applicable for argument types: (com.atlassian.jira.user.BridgedDirectoryUser, java.lang.Long, java.lang.Integer, com.atlassian.jira.issue.IssueInputParametersImpl) values: [kimo:1, 10459, 31, com.atlassian.jira.issue.IssueInputParametersImpl@1eed919] Possible solutions: validateTransition(com.atlassian.jira.user.ApplicationUser, java.lang.Long, int, com.atlassian.jira.issue.IssueInputParameters), validateTransition(com.atlassian.jira.user.ApplicationUser, java.lang.Long, int, com.atlassian.jira.issue.IssueInputParameters, com.atlassian.jira.workflow.TransitionOptions) at Script1273.run(Script1273.groovy:31)
Hello Karim.
I think that you are using a wrong type of user as parameter for the validate function.
Please try to get the user with getJiraAuthenticationContext().getLoggedInUser() instead.
Nice regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.