Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I set the assignee to the current user if no other user is selected during transition??

MoBe February 16, 2015

I'm trying to set the assignee during a transition. I would like to assigne the user, selected in the default assigneepicker of the transitionscreen, or if it's on automatic or not selected to set the current user as assingee.

Does anyone have an Idea how to handle this?

Mo

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2015

You could definitely achieve that by creating a custom script post-function with Script Runner that does something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def Issue issue = issue
if (!issue.assignee || issue.assignee.name == "myAutomaticUser") {
    def currentUser = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()
    issue.assignee = currentUser
}
MoBe February 16, 2015

Hi Alejo, thank you for your input. Do I need to replace myAutomaticUser with the user name to be expected? Or may I can also directly query the "automatic assignment" option from the transition screen? So far I'm not yet the JIRAGroovyInternalsDeveloperGuy... but maybe I am becoming so.

Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2015

Yes, you will need to replace myAutomaticUser with the username of the default assignee of the project.

MoBe February 17, 2015

OK understand. Then I have to preparde a longer List of assignees corresponding to the selected component and project. Is ther now way to query the transition screen from a post function?

Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2015

Why would you need a list of assignees? Sorry, I probably don't understand your question.

MoBe February 18, 2015

Because we haven't a default assingee by project. We use just the default assingee per component.

Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2015

ok, that makes sense. In that case you could do something like this: import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue def Issue issue = issue if (!issue.assignee || issue.componentObjects.any { it.name == issue.assignee.name}) { def currentUser = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser() issue.assignee = currentUser }

MoBe February 18, 2015

You are great! I will try this later. THX

0 votes
Jens Helmstedt August 3, 2016

I tried this in Open transition but it doesn't work there. In another transition it works fine.

So what's the reason why?

Whar can I do?

0 votes
Pedro Cora
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 16, 2015

You can probably use the Script Runner Add-On to craft a script that will do that for you. By default this is not possible in JIRA.

-- Pedro

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events