Hello,
I'm trying to set a user to a nfeed-user field.
I get the following error:
Cannot cast object '[username(username)]' with class 'java.lang.String' to class 'com.atlassian.jira.user.DelegatingApplicationUser'
Code:
def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class)
Issue issue = issueManager.getIssueByCurrentKey("ABC-111")
def Managers = customFieldManager.getCustomFieldObject("customfield_11111")
ArrayList ManagersVal = ['[username(username)]'] as ArrayList
DelegatingApplicationUser PManagers = ManagersVal.get(0) as DelegatingApplicationUser;
IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issueMutable = im.getIssueObject(issue.getKey())
issueMutable.setCustomFieldValue(Managers, PManagers)
def curUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
im.updateIssue(curUser, issueMutable, EventDispatchOption.ISSUE_UPDATED, false);
I guess the error line is
DelegatingApplicationUser PManagers = ManagersVal.get(0) as DelegatingApplicationUser;
If you want to receive AppicationUser from the user name you should use
ApplicationUser PmManager = ComponentAccessor.getUserManager().getUserObject("userName")
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.