I have a working script below on my custom field called Target System with two values JIRA and Confluence and will assign to the desired user based on what you select once you create the ticket. However, I want to set another conditional that should the reporter know who to assign the issue to then it won't auto assigns.
Example 1: I select JIRA under the Target System field and assign to John Doe, then it will leave the assignee to John Doe.
Example 2: I select JIRA under the Target System field and leave assignee automatic then will automatically assign to JIRA TEAM.
My post function script below:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
String userName;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("Target System")
def cfTargetSystem = issue.getCustomFieldValue(cf)
switch(cfTargetSystem){
case "JIRA": userName = "JIRA Team";break;
case "Confluence)": userName = "Confluence Team";break;
}
log.error(userName)
log.error(cfTargetSystem);
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issue.setAssignee(ComponentAccessor.getUserManager().getUser(userName))
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)