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 ?
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"))
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.
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.