There are multiple components in the project, tickets get assign to users base on the component, for example if user select component "Product" then ticket gets assign to product lead, whenever he change status to "Approval Need" it should get assign to a Supervisor. I can add a supervisor in Post function but there are multiple components and there is only one work flow and issue type. If add user there then all ticket assign to him which we don't want, each component has there own lead and supervisor. For example Product component go product team, Customer components ticket assign to Customer team and Supplier to supplier team.
There is two approval Supervisor, I want to create two variable user1 and user2, if user select component "Product" to create a ticket, it should assign user2 otherwise it should add user1 to customer assignee field, then I'll use that assignee field in a User define Post function in workflow, so whenever product lead change the status it should get assign to Product Supervisor, rest of the component it should do nothing or assign to user1. I am trying add following Listener script but it won't working, I know it is not correct, I don't have an idea how to make it work.
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.db.DatabaseUtil
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.sql.Timestamp
import com.atlassian.jira.bc.project.component.ProjectComponentdef event = event as IssueEvent
def issue = event.issue
def customFieldObjects = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)
def user1 = 'abc'
def user2 = 'xyz'def cfAsignee = customFieldObjects.findById("customField_10401")
def components = getFieldById(getFieldChanged()).getValue() as List<ProjectComponent>
if(components == 'Product') {
cfAsignee.modifiedValue(user2)else
cfAsignee.modifiedValue(user1)
}
Thank you