I realize this topic has been posted before but I've spent quite a bit of time searching, and I've tried multiple methods to populate a user field and I'm still unsuccessful.
Just to isolate where I'm having difficulty, I have a user id (which will be set to a variable) and I want to use that value to populate a single user custom field (Division Lead)
I'm using JIRA 7.1.2, and the Script Console. The result = CarlA(carla), but the Division Lead doesn't get updated.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUser
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueObject("TEST-67")
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def dl = customFieldManager.getCustomFieldObjectByName("Division Lead")
ApplicationUser user = ComponentAccessor.getUserManager().getUserByName('carla')
issue.setCustomFieldValue(dl, user)
Hello Andrea.
This seems odd, do the logs provide any information?
Cheers!
DYelamos
I either don't have any logs to review or I'm looking in the wrong place. What log files should I be reviewing?
Thanks, Andrea
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You shuold look for the JIRA logs using the SR log viewer
Can you replace your script with this and then check the logs?
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUser
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueObject("TEST-67")
log.debug "BEGIN DEBUGGER: ISSUE " + issue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def dl = customFieldManager.getCustomFieldObjectByName("Division Lead")
log.debug "DEBUGGER CUSTOMFIELDS " + dl
ApplicationUser user = ComponentAccessor.getUserManager().getUserByName('carla')
issue.setCustomFieldValue(dl, user)
See the lines with BEGIN DEBUGGER and DEBUGGER CUSTOMFIELDS and copy paste them to me.
Cheers!
Dyelamos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.