Getting Current Workflow inside the Configuration Page of a PostFunction

Hi Atlassians,

I'm developing a postfunction that allows transitioning issues after the current transition is completed, based on a certain condition. In other words, this post-function will automatically transition an issue if the provided condition holds true.

In the configuration page of that postfunction, I'm displaying all ActionDescriptors of all workflows (as shows below snapshot).

Inside the method getVelocityParamsForInput of AutoTransitionPostFunctionFactory, I have the following:

@Override

protected void getVelocityParamsForInput(Map<String, Object>velocityParams){

Collection <JiraWorkflow> workflows = workflowManager.getWorkflows();

List<String> listActions = new ArrayList<String>();

for(JiraWorkflow jiraWorkflow : workflows)

{

Collection<ActionDescriptor> actions = jiraWorkflow.getAllActions();

for(ActionDescriptor action : actions)

{

listActions.add(action.getName()+ " (" +action.getId()+")");

}

}

velocityParams.put(TRANSITION_CONDITION, "");

velocityParams.put(WORKFLOW_ACTIONS_LIST, listActions);

}

This code gets all ActionDescriptors of ALL workflows. Is there a way to know the current workflow inside AutoTransitionPostFunctionFactory to get ActionDescriptors of the current one instead of loading all ActionDescriptors of ALL workflows?

Thanks,

Rosy

2 answers

1 accepted

This widget could not be displayed.

Hi Rosy,

I found a way in Jamie Elchin's answer.

https://answers.atlassian.com/questions/35654

 

You should HttpServletRequest parameter for this operation. Using HttpServletRequest parameter you can get workflow name and then you can easily get workflow's components, such as statuses, transitions, etc.

 

I put below code into my validator plugin getVelocityParamsForInput method, and I could list statuses of related workflow. 

 

WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();

HttpServletRequest httpServletRequest = ServletActionContext.getRequest();
String workflowName = httpServletRequest.getParameter("workflowName");
List<Status> workflowStatuslist = workflowManager.getWorkflow(workflowName).getLinkedStatusObjects();

Thanks Kıvanç, I already applied it and it is working perfectly. Thank you, Rosy

This widget could not be displayed.

Hello,

Any updates concerning this question?

Thanks,

Rosy

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

565 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you