Hi there!
I'm trying to add one more approver to the Approvers custom field using ScriptRunner addon.
What I have:
- Create transition
- The automatically populated Approvers custom field with the Line Manager Jira User Id
I need:
To get the user id from the financeManager role and simply add this to the Approvers custom field to get two user ids in Approvers.
Looks like the code returns the necessary array. However, when I'm trying to create a new issue, I have got only the line manager user id in the Approvers field.
What's wrong?
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager.class) as ProjectRoleManager
ProjectRole financeRole = projectRoleManager.getProjectRole("Finance Manager")
ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(financeRole, issue.getProjectObject())
def financeManager = actors.getUsers().toList()?.first();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def approversField = customFieldManager.getCustomFieldObjectByName("Approvers")
List<ApplicationUser> approvers = (List<ApplicationUser>)issue.getCustomFieldValue(approversField)
log.info(approvers); //get [line manager user id]
approvers.add(financeManager);
issue.setCustomFieldValue(approversField, approvers) //get only line manager user id
log.info(approvers); //get [line manager user id, finance manager user id]
Thanks in advance.
approversField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(approversField), approvers), new DefaultIssueChangeHolder())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.