Hi,
I'm trying to auto-share (add to Participant List) certain Jira Service Desk Issue Types when they are created. It is a customer User-Picker field and I'd like them to get notifications etc... as soon as ticket is created.
I've researched and found the script below but I get an error and it doesn't work -
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import java.util.ArrayList
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.CustomFieldManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserUtil()
def requestParticipantsField = customFieldManager.getCustomFieldObject("Approving Manager")
def issueManager = ComponentAccessor.getIssueManager()
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueIndexManager = ComponentAccessor.getIssueLinkManager()
def getUsersAsArray = {
def users = ["ben", "steve"]
ArrayList<ApplicationUser> userList = new ArrayList<ApplicationUser>()
users.each {
def user = userManager.getUserByName(it)
if(user)
{ userList.add(user) }
}
return userList
}
MutableIssue myIssue = issue
ArrayList<ApplicationUser> applicationUsers = getUsersAsArray()
myIssue.setCustomFieldValue(requestParticipantsField, applicationUsers)
Error is with this line "def customFieldManager = ComponentAccessor.getCustomFieldManager()"
and Error states - variable "customFieldManager" masks a binding variable of the same name
I am by no means a groovy script writer or coder so any help is seriously appreciated in detailed steps. Thank you!
Hi Alexandra,
I will point you to some resources that might be helpful to you:
Adaptavist Library
It's a website with a collection of groovy scripts you can use in your ScriptRunner. When I'm creating my own script I use this website and it helps me a lot. I hope it helps you too.
https://library.adaptavist.com/
SR Script Webinar
It is a webinar that it happened, showing a senior developer creating a script from scratch and explaining the why's and how's whilst doing it. Again, it helped me a lot at the beginning of my journey writing my own scripts.
https://www.adaptavist.com/webinars/groovy-scripting-for-scriptrunner/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.