Fix denoted below.
Will your custom field with user name be a User Picker or a Free Text field?
Either way, you should be able to just read that field's value with something like :
import com.atlassian.jira.component.ComponentAccessordef cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName('Some Field with a user')def user if(cf.cusomtFieldType == 'com.atlassian.jira.plugin.system.customfieldtypes:userpicker'){ user = issue.getCustomFieldValue(cf)} else { def userName = issue.getCustomFieldValue(cf) user = ComponentAccessor.userManager.getUserByName(userName)}issue.setAssignee(user)
I wouldn't actually write it this way -- with the "if". You should already know which type your customer field is. But this should show you both ways to get a user object that can then be applied to the issue assignee field
And if you are doing this in a workflow post function, make sure that the script is before the "Update change history for an issue and store the issue in the database" step.
I had resolved this with the following script:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.CustomFieldManagerimport com.atlassian.jira.user.ApplicationUserimport com.atlassian.jira.user.util.UserManagerCustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()def cField = customFieldManager.getCustomFieldObject("customfield_10077")ApplicationUser user = issue.getCustomFieldValue(cField) as ApplicationUserUserManager userManager = ComponentAccessor.getUserManager();issue.setAssignee((user))
As a post function.
Thank you for this!
It looks like you're new here. Sign in or register to get started.