How to set username to a user picker cf? Edited

I'm new to groovy and to the Script Runner. 

We are using Script Runner 5.2.1 and JIRA Server 7.5.1

In a post function I'm trying to populate 2 User Picker cf's with the component lead and component watchers.  I have figured out how to query the db and return both userID for the lead and watcher, now I need to populate them in the user picker fields and for the life of me I can't figure out how to do it, any help would be greatly appreciated.

This is what I have so far.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

//Just for testing the script I'm pulling in a specific issue, when I add this as a post function, I'll modify this line by adding issue
MutableIssue issue = "cc-9396"


MutableIssue SubjectIssue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def validateUserCN = SubjectIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Business Reviewer"))

SubjectIssue.setCustomFieldValue(validateUserCN, "t16384");

 

2 answers

Can anyone help answer this, I would think it's pretty straight forward.

Don't have the methods handy, but if you're still looking. you dont need the db for this, component lead and watchers you can grab from the api - they will also return ApplicationUser objects.

To set the field value, you'll need to actually update the field. Top of my head, i think it was something like ModifiedFieldValue...

 

Maybe that gets you looking in the right direction (if you're still looking ;)  )

 

Cheers

D

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

849 views 2 9
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