Assigning using a post function does not assign properly

Hello.

I've created a post script function in a transition for automated assignment.

The script is post function is followed by the standard store and indexing functions.

This works sometimes fine, sometimes not.

First the script:

.......................

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption

def versionManager = ComponentAccessor.getVersionManager()
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def Betreft = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Vraagcategorie")) as Map
def Hoofdcategorie = Betreft.get(null) as LazyLoadedOption
def Subcategorie = Betreft.get("1") as LazyLoadedOption
def Regio = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("(Informatie) Regio")) as LazyLoadedOption
def Afwijking = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Melding afwijking")) as LazyLoadedOption

if (Afwijking.getValue()=="X" ) {
issue.setAssigneeId("userx@gmail.com")

} else if (Subcategorie.getValue()=="Y" ) {
issue.setAssigneeId("usery@gmail.com")

} else if (Subcategorie.getValue()=="Z" && Regio==null ) {
issue.setAssigneeId("userz0@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="1" ) {
issue.setAssigneeId("userz1@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="2" ) {
issue.setAssigneeId("userz2@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="3" ) {
issue.setAssigneeId("userz3@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="4" ) {
issue.setAssigneeId("userz4@gmail.com")

} else {
issue.setAssigneeId("userA@gmail.com")
} 

......................

The strange thing is that with userx and usery the assignee is set to the user asked.

For the other users, the assignee is filled but seen as not set.

When I open the issue, the user seems set but the picto is a question.

When entering the name the assignment is set.

I've no idea whats the difference between the users.

All are assignable.

All have logged in once.

All have the same permissions.

I've no clue

Anyone?

assignmentproblem.jpg

2 answers

1 accepted

Hi Arco,

I would suggest to use 

def user = ComponentAccessor.getUserManager().getUserByName("username")
issue.setAssignee(user)

instead of assigneeId.

Second thing, you should make sure that the post function is the first one or at least before the "Update change history for an issue and store the issue in the database." step.

regards, Thanos

Yesss! That did the trick. The first part, defining 'user'.

Still don't understand why setAssigneeID works inconsequent, but thats not my problem any more!

Thank you very much! Made my day!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

108 views 0 2
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