Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to get application user instead of delegating app user Groovy

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 04, 2021

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!

1 answer

1 accepted

1 vote
Answer accepted
arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 04, 2021

Labels needs to be a set, not a string

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events