I have 2 custom fields, Assigned Employee is a Select List field (dropdown), Employee Email is a Text Field.
Based on the selected string value in the select list field, I want to auto populate the text field.
I want this to occur while data is being entered, not during a transition.
I had no issue doing this with Issue Type, and updating default descriptions based on issue type selection, but I cannot for the life of me figure out the syntax to do it with custom fields. I've tried about 20 different examples online.
What is the correct syntax?
This is where I'm at, the resulting behavior of the script below is that I click create, and it falls into the else condition right away and updates the email field with the word 'placeholder', then, if I select John Doe from the dropdown list, nothing happens.
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def employee = getFieldByName("Assigned Employee")
def email = getFieldByName("Employee Email")
def employeeVal = employee.getValue()
if(employeeVal.toString() == "John Doe")
{
email.setFormValue("john.doe@email.com")
}
else
{
email.setFormValue("placeholder")
}