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

This widget could not be displayed.

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

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

126 views 1 3
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