Field Required on Transition
Making a field required for a given project for a particular transition, using the workflow validator
You can use Jira Suite Utilities to make fields required on certain transitions, the problem is they are not shown as required until you submit. Create a new behaviour or edit an existing one. Click the Enable link next to "Use Validator Plugin". Ensure this behaviour is associated with a project.
When going through a transition that requires a field, these should be shown as required before you submit. In this example I have added Fields Required validator on the Resolve action.
Set one field based on another field with information provided by the server
In this next contrived example, we will set a read-only field with the component lead’s user name. You need a server validator on the Component field to get the component lead, and you will make another field read-only.
Create a User-type field, in this example I’ve called it UserPicker (if you try this example you must call the field the same thing, unless you modify the code). The behaviour should look like this:
Of course the path to your script will probably be different. This script in this case is:
import com.atlassian.jira.bc.project.component.ProjectComponent
def formComponent = getFieldById(fieldChanged)
def formUserField = getFieldByName("UserPicker")
def components = formComponent.getValue() as List<ProjectComponent>
// if any components have been set, set the user field to the component lead of the first component
// otherwise unset it
if (components) {
formUserField.setFormValue(components.first().lead)
} else {
formUserField.setFormValue("")
}
This illustrates an alternative way of changing the behaviours using the UI rather than code, to make the user field is read-only. In general it’s preferable, and more portable and flexible, to set behaviours using code rather than the UI.
On selecting a component the field value should change:
If you remove all components it will be cleared.