Missed Team ’24? Catch up on announcements here.

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

Set Assignee from Custom Field

Heiko December 6, 2019

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

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Yury Lubanets December 6, 2019

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)
}

Heiko December 6, 2019

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

Yury Lubanets December 6, 2019

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

Heiko December 6, 2019

Has no Effect

Heiko December 6, 2019

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

issue.setAssignee(cFValue.username.toString())
Like Alexander Bondarev likes this
0 votes
RichardA April 14, 2020

Hi all,

how can we set the multiple assignee's in jira

Thanks.

Heiko April 21, 2020
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
TAGS
AUG Leaders

Atlassian Community Events