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")
}
You can disregard my question. I figured out what I was doing wrong, the Initializer script by definition only fires once when the form loads. Pretty obvious in retrospect, but I just need to script individual fields within the behaviors module, not via the initializer script feature.
What through me off what the first example I did from the docs, that shows how to script default values in the description field based on issue type. I guess the key difference there is that the issue field is a key out-of-the-box field that triggers a form load, whereas changing the value in a custom field does not.
Really enjoying the product so far! :)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.