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 { == 'Dev Engineer'};
    def userPicker2     = customFieldManager.getCustomFieldObjects(event.issue).find { == 'Test Responsible'};
    def textField1      = customFieldManager.getCustomFieldObjects(event.issue).find { == 'Test Case'};
    def dbFieldValue1   = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(event.issue).find { == 'Database Field 1'});
    def dbFieldValue2   = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(event.issue).find { == 'Database Field 2'});
    def dbFieldValue3   = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(event.issue).find { == '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
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


264 views 0 7
Read article

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