Result of getDescriptorParams is not available in post function's execute args

I am starting to write a JIRA workflow post function plugin, which needs to have a persistent configuration.

Things are working as expecated when it comes to the configuration page. There is a velocity template which is used for both edit- and input-params. It is possible to persist the configuration values and to load them in the configuration's web form.

I am extending AbstractWorkflowPluginFactory implementing WorkflowPluginFunctionFactory as my plugin's function factory.

getDescriptorParams is providing a Map of all the necesarry key-value-pairs.

Afaik getDesciptorParams results are meant to be passed in the 'arg' parameter of post-functions' execute().

The problem is, when I try to implement the post function (extends AbstractJiraFunctionProvider), execute is not getting the values provided by getDescriptorParams. I only see two key-value-pairs for the keys "class.name" and "full.module.key" (both point out correct values for my plugin, but I neither set them in getDescriptorParams nor I need them) but nothing else when debugging.

Again I used the debugger to check the outcome of getDescriptorParams: When persisting the configuration, the result of getDescriptorParams is clearly containing the result I wish to use in execute()'s args.

What am I missing?

1 answer

@Thilo Fester

Well you are almost there. I can give you a small example with a parameter of say project_key

The factory class will look something like :

public class FunctionFactoryTest extends AbstractWorkflowPluginFactory implements WorkflowPluginFunctionFactory{

 private static final String PROJECT_KEY = "project_key";
 
 @Override
 protected void getVelocityParamsForEdit(Map velocityParams, AbstractDescriptor inDescriptor) {
  FunctionDescriptor descriptor = (FunctionDescriptor) inDescriptor;
  
  String currentProjectKey = (String) descriptor.getArgs().get(PROJECT_KEY);
     velocityParams.put(PROJECT_KEY, currentProjectKey);
 }
 
 @Override
 protected void getVelocityParamsForInput(Map velocityParams) {
     velocityParams.put(PROJECT_KEY, "");
 }
 
 @Override
 protected void getVelocityParamsForView(Map velocityParams, AbstractDescriptor inDescriptor) {
  FunctionDescriptor descriptor = (FunctionDescriptor) inDescriptor;
  
     velocityParams.put(PROJECT_KEY, descriptor.getArgs().get(PROJECT_KEY));
 }

 public Map getDescriptorParams(Map conditionParams) {
  Map<String, String> params = new HashMap<String, String>();
  params.put(PROJECT_KEY, extractSingleParam(conditionParams, PROJECT_KEY));
     return params;
 }
}

The execute function can be used to get the project value like this:

@Override
 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException {
  String projectKey = (String) args.get("project_key"); 
  }

and then you can form the velocity files to render the value easily from this class using the variable names correctly as given in the map.

<input type="text" name="project_key" value="$project_key"/>

A more detailed explanation with working example can be found from this link by Jtricks. workflow-post-function implementation

Thanks Satyam. I found out I forgot to publish my workflow draft m/. Thanks for your support anyway.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,811 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot