Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Assignee as a custom field value- User Picker

Swarna Radha
Contributor
June 29, 2018

Hi ,

I want to set assignee based on user picker custom field but the issue is that it is assigning the issue to the reporter not the value on the custom field.

Please see code:

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
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

def cField = customFieldManager.getCustomFieldObject("customfield_10601")
ApplicationUser user = issue.getCustomFieldValue(cField) as ApplicationUser
UserManager userManager =   ComponentAccessor.getUserManager();
issue.setAssignee((user))
Thanks

 

1 answer

1 accepted

0 votes
Answer accepted
Mark Markov
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.
June 29, 2018

Hello @Swarna Radha

Try this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

def cField = customFieldManager.getCustomFieldObject("customfield_10601")
ApplicationUser user = issue.getCustomFieldValue(cField) as ApplicationUser
issue.setAssignee(user)
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
Swarna Radha
Contributor
June 29, 2018

Hi Mark,

It is the same. It is making reporter as assignee instead the value in the custom field. 

Note: when i am using the custom field on Create

 

Thanks

Swarna Radha
Contributor
June 29, 2018

test

Swarna Radha
Contributor
June 29, 2018

test

Mark Markov
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.
June 29, 2018

It looks like something else changes assignee.

Is this postfunction? try to move it on last position.

Swarna Radha
Contributor
June 29, 2018

It is a post function. Now it is working after move it on last position ..

Thanks

Mark Markov
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.
June 29, 2018

You re welcome!

If this helps you, please mark answer as accepted :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events