Hi
I want to accomplish the following requirement but constantly encounter problems=)
1) When an issue got created in a certain project and assignee is set as Default Assignee I need to change assignee to a specific user according to issue type (I have three issue types in that project and each one should go to its own default assignee)
First I've tried to run groovy script in a post action when issue is created in the workflow designed. This didn't work, Jira ignores this and uses proeject's default assignee. The order of post functions didn't matter
Then I tried to create a custom listner, attach to IssueCreated event and do the trick - but result is this the same.
I've found this article https://answers.atlassian.com/questions/191021/groovy-change-assignee-based-on-custom-field-valuebut I don't really like the idea of creating a scripting field.
Is there any, more elegant, way of doing this?
I've finally made it
The trick was that I did everyting correctly in the very begining. Abovementioned bug with switch statement was a bad guy.
so
1) This won't work if you do it in the event listner
2) the only way was to add a script as workflow post function and set it to be executed before IssueCreated event
I suspect the problem is that the decisions made by you selecting "default user" are being made before your code runs, so your listener and post-functions don't actually know the default was set. It might be useful to show us the exact code you have for them.
My other guess is that your user doesn't have "assign issues" - the functoins will respect the permissions and ignore your user unless they have the rights to assign issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic
My other guess is that your user doesn't have "assign issues" -
Well all users have Assignable User permissions. I've already checked that, so this not the issue.
It might be useful to show us the exact code you have for them.
Sure, here is my code sample in form of lisnter
imports.... class InceptionDefaultAssignee extends AbstractIssueEventListener { Category log = Category.getInstance(InceptionDefaultAssignee.class) @Override void workflowEvent(IssueEvent event) { super.issueCreated(event) //To change body of overridden methods use File | Settings | File Templates. ComponentManager componentManager = ComponentManager.getInstance() def permissionManager = componentManager.getPermissionManager() def user1 = componentManager.getUserUtil().getUser("user1") def user2 = componentManager.getUserUtil().getUser("user2") def user3 = componentManager.getUserUtil().getUser("user3") MutableIssue currentIssue = issue switch (currentIssue.issueTypeId) { //bug case 1 : if (permissionManager.hasPermission(Permissions.ASSIGNABLE_USER, issue, user1)) { currentIssue.setAssignee(user1) } break //task case 3 : if (permissionManager.hasPermission(Permissions.ASSIGNABLE_USER, issue, user2)) { currentIssue.setAssignee(user2) } break //question case 36 : if (permissionManager.hasPermission(Permissions.ASSIGNABLE_USER, issue, user3)) { currentIssue.setAssignee(user3) } break default: break } } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is also not the root cause unfourtunately=( all users (including one that creates the issue) have both Can Assigne and Assignable User permissions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, it's not that then.
In your code, are you sure the "getuser" calls are actually getting any users? The calls you're using are deprecated if I remember correctly, but I'm wondering if they return nulls (if they do, it would explain why the setAssignee does nothing)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your code, are you sure the "getuser" calls are actually getting any users?
Yep, this works fine. I've added logging - user is populated correctly
However, I've found two bugs in my code
However even when I fixed all the bugs - result is still the same=(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.