How to assign custom field value to a single user picker?

I am trying to update the values of a few fields when an issue is edited in certain statuses. The text fields that I need to update are pretty straight forward and are getting updated. However I have a couple of single user pickers which I am unable to set. The source fields are database custom fields (using Power Database Fields). Below is the code I am currently using. Please help me understand where I am going wrong.

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor

def issue               = event.issue as Issue;
def customFieldManager  = ComponentAccessor.getCustomFieldManager();
def issueStatus         = issue.getStatus().name;

if(issueStatus == 'status1' || issueStatus == 'status2')
{
    def userPicker1     = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == 'Dev Engineer'};
    def userPicker2     = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == 'Test Responsible'};
    def textField1      = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == 'Test Case'};
    
    def dbFieldValue1   = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(event.issue).find {it.name == 'Database Field 1'});
    def dbFieldValue2   = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(event.issue).find {it.name == 'Database Field 2'});
    def dbFieldValue3   = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(event.issue).find {it.name == 'Database Field 3'});

    def changeHolder    = new DefaultIssueChangeHolder();
    
    userPicker1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(userPicker1), dbFieldValue1),changeHolder);
    userPicker2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(userPicker2), dbFieldValue2),changeHolder);
    textField1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(textField1), dbFieldValue3),changeHolder);
}

We are using JIRA Software version 7.3.6.

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

144 views 3 4
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you