I have spent all weekend trying different solutions proposed here for my issue. I have not had success. Please help. The code that I get to work does not seem to be adding an actual user from the directory. The entries appear to be string only. I execute this code in the Additional Issue actions section of the create Sub-Task script during the create issue transition of the parent issue.
My code is below.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Direct Manager'}
java.lang.String user22 = sourceIssue.getCustomFieldValue(cf)
issue.setAssigneeId(user22)