I am trying to set the value of a custom field based on another field.
Ie:
If custom field Application = Salesforce
Set custom field Additional Assignees = User1
I have a custom script-runner post script function already so I would just try to add to the existing.
So far it auto assigns the ticket if Application = Salesforce but I'd like to add an additional assignee to it.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
//import org.apache.log4j.Level
//import org.apache.log4j.Logger
//def log = Logger.getLogger("com.acme.postfunction")
//log.setLevel(Level.DEBUG)
def applicationCf = customFieldManager.getCustomFieldObjectByName("Application")
def additionalassigneesCf = customFieldManager.getCustomFieldObjectByName("Additional Assignees")
def application = issue.getCustomFieldValue(applicationCf) as String
if (application == "Application1") {
issue.setAssigneeId("Person1")
} else if (application == "Salesforce") {
issue.setAssigneeId("Guy1")
@Jh sorry for late response. Problem you have to solve is that you need to set array of users as value for your Additional Assignees field, it should be something like
def userManager = ComponentAccessor.getUserManager()
def user = null
if (application == "Application1") {
issue.setAssigneeId("Person1")
user = userManager.getUserByName("Person1")
} else if (application == "Salesforce") {
issue.setAssigneeId("Guy1")
user = userManager.getUserByName("Guy1")
}
if(user){
issue.setCustomFieldValue(additionalassigneesCf, [user])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.