I have this code (JIRA Server 8.6):
if (state && state != "")
{
//Find "State" Action from here
JiraWorkflow workFlow = ComponentAccessor.getWorkflowManager().getWorkflow(mIssue)
def status = mIssue.getStatusObject()
StepDescriptor currentStep = workFlow.getLinkedStep(status)
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Current Step: " + currentStep.getName() + " found.'"
List<ActionDescriptor> actions = currentStep.getActions()
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Action: " + actions.size() + " found.'"
for (Iterator<ActionDescriptor> iter = actions.iterator(); iter.hasNext();)
{
ActionDescriptor actionDescriptor = (ActionDescriptor) iter.next()
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Action: " + actionDescriptor.getName() + " found.'"
if (actionDescriptor.getName().toLowerCase() == state.toLowerCase())
{
actionId = actionDescriptor.getId()
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Found ActionDescriptorId: " + actionDescriptor.getId() + "'"
}
}
and it returns 0 actions.... I have no clue why... permissions are in order and Im 99,999% sure it has been working.
The log part:
Current Step: To Do found.
is correct, so I have a handle to the correct Step.
Log is:
020-03-27 12:03:23,663+0000 http-nio-8080-exec-1 INFO servicenowautomation 723x164703x1 1gekzbz 10.237.193.165,127.0.0.1 /rest/scriptrunner/latest/custom/updateincident [c.o.scriptrunner.runner.AbstractScriptRunner] Script=updateincident.groovy ScriptRunIdent=53501 Action=Start
2020-03-27 12:03:23,664+0000 http-nio-8080-exec-1 INFO servicenowautomation 723x164703x1 1gekzbz 10.237.193.165,127.0.0.1 /rest/scriptrunner/latest/custom/updateincident [c.o.scriptrunner.runner.AbstractScriptRunner] Script=updateincident.groovy ScriptRunIdent=53501 Message='Issue: AL-100 found.'
2020-03-27 12:03:23,665+0000 http-nio-8080-exec-1 INFO servicenowautomation 723x164703x1 1gekzbz 10.237.193.165,127.0.0.1 /rest/scriptrunner/latest/custom/updateincident [c.o.scriptrunner.runner.AbstractScriptRunner] Script=updateincident.groovy ScriptRunIdent=53501 Message='Current Step: To Do found.'
2020-03-27 12:03:23,665+0000 http-nio-8080-exec-1 INFO servicenowautomation 723x164703x1 1gekzbz 10.237.193.165,127.0.0.1 /rest/scriptrunner/latest/custom/updateincident [c.o.scriptrunner.runner.AbstractScriptRunner] Script=updateincident.groovy ScriptRunIdent=53501 Message='Action: 0 found.'
2020-03-27 12:03:23,665+0000 http-nio-8080-exec-1 INFO servicenowautomation 723x164703x1 1gekzbz 10.237.193.165,127.0.0.1 /rest/scriptrunner/latest/custom/updateincident [c.o.scriptrunner.runner.AbstractScriptRunner] Script=updateincident.groovy ScriptRunIdent=53501 Error='Transition: Done could not be found.'
This worked for all-to-all:
// Test for all-to-all workflows
if (actionId == 0)
{
def availableActions = ComponentAccessor.getComponentOfType(IssueWorkflowManager.class).getAvailableActions(mIssue, serviceNowAutomation)
availableActions.each { theAction ->
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Found Action: " + theAction.getName() + "'"
if (theAction.getName().toLowerCase() == state.toLowerCase())
{
actionId = theAction.getId()
}
}
}
Nice, the user passed apparently makes the difference in getAvailableActions(issue, user) vs. the linkedStep.getActions() which takes no user as an argument.
Note, I had to include the following import to make this work:
import com.atlassian.jira.workflow.IssueWorkflowManager
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is not working either (buts its woking in another jira...):
if (state && state != "")
{
//Find "State" Action from here
JiraWorkflow workFlow = ComponentAccessor.getWorkflowManager().getWorkflow(mIssue)
def status = mIssue.getStatusObject()
StepDescriptor currentStep = workFlow.getLinkedStep(status)
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Current Step: " + currentStep.getName() + " found.'"
StepDescriptor stepDescriptor = workFlow.getDescriptor().getStep(currentStep.getId())
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='StepDescriptor: " + StepDescriptor + "'"
for (Iterator<ActionDescriptor> iter = stepDescriptor.getActions().iterator(); iter.hasNext();)
{
ActionDescriptor actionDescriptor = (ActionDescriptor) iter.next()
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Action: " + actionDescriptor.getName() + " found.'"
if (actionDescriptor.getName().toLowerCase() == state.toLowerCase())
{
actionId = actionDescriptor.getId()
log.info "Script=" + scriptName + " ScriptRunIdent=" + scriptRunIdent + " Message='Found ActionDescriptorId: " + actionDescriptor.getId() + "'"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, It works in "sequentical" workflows .. but not in a mesh (all status to all statuses)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.