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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Set Assignee from Custom Field

Hello everybody i would like to set the Assignee from a user picker custom field see code Below but nothing hapens

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
def cField=ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10401")
def cFValue = issue.getCustomFieldValue(cField) as ApplicationUser
issue.setAssignee(cFValue)

 

2 answers

1 accepted

0 votes
Answer accepted

Hello @Heiko Treuner 

Where do you do it? In post functions, in listeners, in the console?

If it's a post-function it should be upper then 'Update change history for an issue and store the issue in the database.' function. In other cases, you should use issue update methods. For example

def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setAssigneeId("userName")

def updateValidationResult = issueService.validateUpdate(user, issue.getId(), issueInputParameters)

if (updateValidationResult.isValid()) {
issueService.update(user, updateValidationResult)
}

Hey thaks for ur answer i used it in the create post function and have it before 'Re-index an issue to keep indexes in sync with the database. ' but nothing happens

Try to move your function to the first place just before 'Creates the issue originally.' function

ok if found the reason by myself i have to do this below:

issue.setAssignee(cFValue.username.toString())
Like Alexander Bondarev likes this

Hi all,

how can we set the multiple assignee's in jira

Thanks.

def cField=ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10401")

With this snippet you get a specific field where you can do what you want e.q. set other fields like the asignee field. If th fetched value a user picker field

Like RichardA likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Desk

Calling all Insight users, we need your help!

Hello Insight users,  As part of our (Mindville's) acquisition by Atlassian, our training team is looking to build some new Insight training materials. It would really helpful if you can ...

135 views 1 0
View question

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you