Hey community,
i am trying to auto-transition an issue using a script listener depending on a linked issue but there is an error i don't really understand:
t seems that you have tried to perform a workflow operation (Done) that is not valid for the current state of this issue (FOSS-15). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.
Although the issue history is empty at this time.
When I run the same code on the same issue in the script console, the transition works. Do you guys have any clue what possibly have gone wrong?
This is my code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.user.ApplicationUser
// only transition tasks
if (issue.issueType.name != "Task") {
log.warn("This is not a task!")
return
}
def issueService = ComponentAccessor.issueService
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def cfield = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10108")
def linkedIssue = issue.getCustomFieldValue(cfield)
def changeHistoryManager = ComponentAccessor.changeHistoryManager
def actionId = 0
switch (linkedIssue.status.name) {
case "Done":
actionId = 31
break
case "In Progress":
actionId = 21
}
log.error(issue.status)
def issueInputParameters = issueService.newIssueInputParameters()
def validationResult = issueService.validateTransition(user, issue.id, actionId, issueInputParameters)
if (!validationResult.isValid()) {
log.error("invalid transition: ${actionId}")
log.error(validationResult.errorCollection)
log.error(validationResult.warningCollection)
return
}
def transitionResult = issueService.transition(user, validationResult)
if (!transitionResult.isValid()) {
log.error("failed transition")
return
}
Hi
I also suggest use this script on transition (scripted post-function). If you use script runner I would think about use fast-track tranistion post-function. Using this you can very easy create condition what transition should be triggered.
Regards,
Sebastian
Hi,
why do you want to use a listener. I suggest to use a scripted postfunction instead, since you want to attach this feature to a transition anyhow, so there is no need for a listener.
If you want to "Transition at creation" you just need to add the post function to the create transition. Make sure the issue is created before modifying any issue details. (so you have to move down in the post functions config)
Cheers
Heiko
PO@Accxia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your issue is not clear.
Are you talking about
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.