I'm writing a Script Runner listener to automatically transition a linked issue and it's subtasks based on whether a component is added or removed to the base issue.
I see I can get all the available workflow actions using
jiraWorkflow.getAll AvailableActions("");
This lists all the available actions for the whole workflow.
I can also get all the available actions called a name (Reject in this case) with
jiraWorkflow.getActionsByName("Reject");
which can result in several items in my collection if the workflow has several actions(transitions) called Reject
I can iterate through these to find the one that matches the current workflow status and use that, but this seems messy and I'm not confident it's robust to different workflows which may have shared transitions (which give a parent status name of null) and individual transitions with the same name.
Is there a cleaner method to find the available actions for the current point in the workflow?
Hello,
Below code might help. Bear in mind that I did not test it
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
workflow.getLinkedStep(status).getActions();
Nice one, that worked a treat.
For the current status I've used it as follows
workflow.getLinkedStep(issue.getStatus()).getActions();
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.
Please
I'm trying too work with a code like this but...
how can i get the results ??
I've read Atlassatian OnLine Documentation and I saw that "getLinkedSetp" method returns
com.opensymphony.workflow.loader.StepDescriptor
I would like to get the possible transitions (actions) basead on a issue state, just like the code above.
But, I have to fire a transition if I found a particular action.
So, I must handle the Action Name (to search) and the Action ID (to fire) of the actions returned by "workflow.getLinkedStep( issue.getStatus()).getActions()
Is it possible?
Thanks in Advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Forget it
I get it
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.workflow.JiraWorkflow
import com.opensymphony.workflow.loader.ActionDescriptor
JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow( _issue_ )
ActionDescriptor action
int actionID = 0
def actions = workflow.getLinkedStep( issuePai[0].getStatus() ).getActions().iterator()
while ( actions .hasNext() )
{
action= (ActionDescriptor)actions .next()
if( action.getName() == "my condition")
actionID= action.getId()
}
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.