ScriptRunner scripts can be used to work with the values of TFO’s custom field types.
What is the returned value, the original option name, or its translation?
We have a translated custom field dropdown list with ID 10000.
The following options and translations are added:
There is an issue named TEST-1, and we select the option "1" for our new translated custom field.
When logged in with administrator permissions, a new script can be created similar to the following:
import com.atlassian.jira.component.ComponentAccessor ComponentAccessor.getIssueManager().getIssueObject("TEST-1").getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10000"))
The result of this script will be "1".
Therefore, the option name without translation, is returned.
What happens with Behavior scripts?
Besides the above configuration, there is a Single Line Text Field ("Text").
A new Behavior script would look like the following:
def formFieldTFO = getFieldById(getFieldChanged()) def formFieldText = getFieldByName("Text") formFieldText.setFormValue(formFieldTFO.getValue())
Open the Edition or Transition screen where this field appears and change the selected value of the translated custom field.
The selected value can now be seen in the text field. The value returned by formFieldTFO.getValue() is the option name without translation.
If the last line was changed, the Behavior script would look similar to the following:
def formFieldTFO = getFieldById(getFieldChanged()) def formFieldText = getFieldByName("Text") formFieldText.setFormValue(formFieldTFO.getFormValue())
Refresh the form and select another value. Now, the returned value by formFieldTFO.getFormValue() is the option ID.