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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,230
Community Members
 
Community Events
176
Community Groups

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

Has no Effect

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

Atlassian Community Events