pass issue key in getIssueByCurrentKey using groovy

Nishant Kansal April 11, 2016

Hello,

I am trying to develop a post function that should-

Pass the “Issue Key” to “getIssueByCurrentKey” method, once the issue has been created in JIRA for further actions.

or any other way to pass the issue key.

Please help!

Nishant

3 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 12, 2016

In a post-function, you already have access to the issue object, so you can simply say issue.getKey or do whatever else you need directly on the issue.

Nishant Kansal April 13, 2016

Thanks a lot Nic. It worked!!!

0 votes
Aleks Yenin (Polontech)
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.
April 12, 2016

Hi,

For creation post-function try to use following:

import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.workflow.function.issue.AbstractJiraFunctionProvider;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.WorkflowException;

import java.util.Map;

public class ExamplePostFunction extends AbstractJiraFunctionProvider {
    @Override
    public void execute(Map map, Map map1, PropertySet propertySet) throws WorkflowException {
        MutableIssue issue = getIssue(map); //you can get issue key from here or
        String issueKey = (String) map.get("issue"); //return issueKey

        

    }
}

in atlassian-plugin.xml write something like this:

<!-- PostFunctions -->
<workflow-function key="example-function" name="Example Function"
                   class="pathToYouFactoryClass.ExampleFunctionFactory">
    <description>Example Function</description>
    <function-class>pathToYouClass.ExamplePostFunction</function-class>

    <orderable>true</orderable>
    <unique>false</unique>
    <deletable>true</deletable>

    <resource type="velocity" name="view" location="templates/function/functions-view.vm"/>
    <resource type="velocity" name="input-parameters" location="templates/function/functions-edit.vm"/>
    <resource type="velocity" name="edit-parameters" location="templates/function/functions-edit.vm"/>
</workflow-function>

Example Factory class create like this:

public class ExampleFunctionFactory extends AbstractWorkflowPluginFactory implements WorkflowPluginFunctionFactory {
 ...
}
In functions-edit.vm and function-view.vm you can write some text for example.

For more information please see tutorial.

 

 

 

Nishant Kansal April 13, 2016

Hi Aleks, Thanks for your solution.

0 votes
Nishant Kansal April 12, 2016

image2016-4-12 15:40:36.png

The highlighted id for example

Suggest an answer

Log in or Sign up to answer