Assign an issue to different developer in JIRA based on the custom field value

Divyank Dubey July 12, 2016

Hi,

I am trying to automatically assign a issue to a particular developer based on the custom field value.

In my case the custom field is "Product Name" a drop down single selection list.

A

B

C

So based on 'A', 'B' or 'C' , I have to assign the ticket to different developer.

I am not able to find any option of adding an event listener class in the "create" transition of the workflow.

Even using post-function in "create" transition of workflow, I am not able to find any proper way to achieve this.

Can anyone please help me with this ?

1 answer

0 votes
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.
July 13, 2016

Event listeners are not part of a workflow, so you don't see a way to add them.

What you need here is either a post-function OR a listener.  You can use a post-function if you want to do this as part of the workflow (assigning things on issue create, or issue moves into "dev" status or is closed), but if you want to be able to catch any update and change the assignee, you do need a listener.  The most common reason is "I want to change assignee when field X is changed" - post-functions don't catch field updates as they only get run when the status is changed.

Once you've decided where it's appropriate to run your code, you'll need a way to get it into JIRA.  I'd use the Script Runner for this (unless you can find a pre-written add-on which can provide it).  A post-function or listener to set the assignee based on a field are quite easy to do with Script Runner.

For example, the setting of an assignee on create is not much more than

issue.setAssignee( userUtil.getUserByName("admin"))

and then use this to get the customfield value to base your logic on:
issue.getCustomFieldValue (customFieldManager.getCustomFieldObjectByName("Product Name"))
samuel_ballé July 14, 2016

I never made a script in JIRA so I do not know the API.

I need to do almost exactly what you say :

assign issue to member of project role defined in a custom field. Do it from a com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction

Can you point to the good function ?

issue.setAssignee(theGoodFunction(issue.getCustomFieldValue (customFieldManager.getCustomFieldObjectByName("MyCustomField")))

And if imports are necessary please also tell, it's real hard the first time to get where the information is.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events