Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Listener - Setting an additional action to add Label

craig rayner
August 8, 2018

Hi, i have a custom scriptrunner listener that adds a subtask when a certain condition is true. I'm trying to add a label of "Testing" to this subtask in the 'Additional issue actions' part of the listener. The code i've been trying to use is:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager

ApplicationUser user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager.class)
labelManager.addLabel(user, issue.id, 'Testing', false)

 

I'm receiving the following error:

The script could not be compiled:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script51.groovy: 4: unable to resolve class ApplicationUser 
 @ line 4, column 17.
   ApplicationUser user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
                   ^

1 error

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Jon Bevan [Adaptavist]
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 Champions.
October 11, 2017

Hi @Keri Hudson,

I'm pretty sure what you need to change is

customfield_10747 : { value: pmoSprintStatus}

to be:

customfield_10747 : [ value: pmoSprintStatus ]

because in Groovy both maps and lists use square brackets.

Let me know if that doesn't fix things!

Thanks,
Jon

Shrikant Maheshwari
September 10, 2018

@[deleted]

Requirement - 

I want to update a drop down field based on certain condition.

 I am writing the escalation service in which i have enabled the condition in JQL, and now i want to update the issues that are the result of the JQL.

 I have a field named -ReviewRecommendation which has 4 drop down values - None,Hold,Accept, Reject.

 This field is getting set to None by JMWE add-on to "None" value.

 I have one more field named "Due date", now i have written the JQL as - 

 project = PRIYAN and "Review Recommendation"=None and "due" <now()

 Now for  all the issues which are result set of the above JQL, the field "ReviewRecommendation "should be updated to "Accept".

Could you provide me the script for my requirement.

Below is my script which is not working, please help me in resolving it.

def issueKey = issue.key

def ReviewRecommendation = ""

if (issue.fields.customfield_26872 =="None")
{
ReviewRecommendation = "Accept"
}

def result = put("/rest/api/2/issue/${issue.key}")
.queryString("overrideScreenSecurity", true)
.header('Content-Type', 'application/json')
.body([
fields: [
customfield_26872 : [ value: ReviewRecommendation]

]
])
.asString()

TAGS
AUG Leaders

Atlassian Community Events