Hello,
I am trying to create a script that copies the value from a select list field, adds a suffix to it, and then creates a label with that string, upon issue creation. The post function is:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.security.JiraAuthenticationContext;
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def ScrumTeamObject = customFieldManager.getCustomFieldObject(12205)
def ScrumTeamValue = issue.getCustomFieldValue(ScrumTeamObject).toString()
ScrumTeamValue.replaceAll(" ","_")
def suffix = "_Team"
def labelToAdd = ScrumTeamValue + suffix
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext()
ApplicationUser user = authContext.getLoggedInUser()
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
labelManager.setLabels(user,issue.id,labelToAdd,false,false)
The error is :
2021-06-04 11:19:09,668 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed for user 'abc'. View here: https://jira-abc/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=abc&descriptorTab=postfunctions&workflowTransition=1&highlight=1
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.label.DefaultLabelManager.setLabels() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser, null, String...) values: [MARAMA(JIRAUSER83105), null, Engineering_Team, false, false]
Possible solutions: setLabels(com.atlassian.jira.user.ApplicationUser, java.lang.Long, java.util.Set, boolean, boolean), setLabels(com.atlassian.jira.user.ApplicationUser, java.lang.Long, java.lang.Long, java.util.Set, boolean, boolean)
at Script154.run(Script154.groovy:22)
We are using crowd, Jira 8.5.3 . How do I get an application user so that I can set the labels?
Thank you!
Labels needs to be a set, not a string
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.