Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

GetActions on WorkflowStep returns 0 actions

Normann P_ Nielsen _Netic_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2020

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.'

 

2 answers

1 vote
Normann P_ Nielsen _Netic_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2020

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()
}
}
}
Jeff Abbott October 8, 2020

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

0 votes
Normann P_ Nielsen _Netic_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2020

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() + "'"
}
}

 

Normann P_ Nielsen _Netic_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2020

Ok, It works in "sequentical" workflows .. but not in a mesh (all status to all statuses)

Normann P_ Nielsen _Netic_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2020

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events