Hi...I have a script to set the Approvers field that comes with Jira Service Desk to either the component lead and project lead or only to the project lead in a post function on the create transition and it works perfectly. However, the same script as a listener does not work (I need it as a listener because the post function does not execute when an issue is moved to the project). It just does not set the Approvers field. I cant figure out what I have to modify so it works as script listener as well.
Thank you for your assistance. Script below (as I said it works as a post-function but as a listener it does not set the Approvers field)
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.Project import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
projectlead = issue.getProjectObject().getProjectLead()
def components = issue.componentObjects.toList()
if (components)
{ componentlead = components?.first()?.componentLead
}
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customFieldApprovers = customFieldManager.getCustomFieldObjectByName( "Approvers" )
if (components && componentlead != projectlead) { issue.setCustomFieldValue(customFieldApprovers, [projectlead,componentlead])
}else{
issue.setCustomFieldValue(customFieldApprovers, [projectlead])
}