Hi,
I understand that scriptrunner behaviours trigger either on opening up the edit/create screen or editing the field that script is attached to.
I would like to know if it's possible to trigger the script when the "Create" button is pressed o it reevaluates itself at that time.
Here is some context why I want to know this:
This is a snippet of a example script provided by scriptrunner
// Use this snippet if setting a value in one field always requires the user to enter a value in another field
// Change the 'Other Field Name' to the name of the field that should be required if this one has a value.
def currentField = getFieldById(getFieldChanged()) // field this behaviour script is defined on
def otherField = getFieldByName('Other Field Name')
def errorMessage = 'You must also populate this field!'
// set errors to ensure dependant fields are populated
if (currentField.value && !otherField.value) {
currentField.clearError()
otherField.setError(errorMessage)
} else if (!currentField.value && otherField.value) {
otherField.clearError()
currentField.setError(errorMessage)
} else {
otherField.clearError()
currentField.clearError()
}
Lets say we set the "currentField", then script is triggered and tells us that "otherField" is needed. We fill that field as well and click on "Create", however nothing happens because script wasn't triggered. User, after filling out the "otherField" has to go back and edit "currentField" AGAIN to trigger the script, despite the fact its already filled with data that he put there.
This is really not intuitive and user friendly. Can the script be somehow tied to "Create" button so it runs again after clicking it? If not in what other way can this issue be resolved?