Modify Field Descriptions
You can use Behaviours to modify field descriptions, for example, to make a field mandatory and add a description. For example, you can use the following example to make the Description field required and add a note to the field when the Priority of an issue is set to Highest:
- From ScriptRunner, navigate to Behaviours.
- Select Create Behaviour.
- Enter a name for the behaviour. In this example we enter
Modify description field when priority is highest
. - Enter a description for the behaviour. This field is optional.
- Select Create Mapping.
- Then select the project and issue type(s) to map this behaviour to.
- Select Add Mapping to confirm the mapping.
Select Create to create the behaviour.
You're taken to a screen where you can configure the behaviour further.Optional: Enter a guide workflow.
Scroll to the Add Field section and add the Priority field.
- Select Create Script to add a server side script to the Priority field.
Copy the following code into the inline script editor:
def formField = getFieldById(getFieldChanged()) def descField = getFieldById("description") def priority = formField.getValue()?.name if (priority == "Highest") { // choose priority by name descField.setHelpText("Please explain why priority is Highest.") descField.setRequired(true) } else { descField.clearHelpText() descField.setRequired(false) }
After pasting the code, you might encounter a static type error message. This is a common occurrence when working with Groovy scripts in this context. If you want to get rid of this error you can update line 4 to the following:
groovydef priority = (formField.getValue() as com.atlassian.jira.issue.priority.Priority)?.name
This tells the compiler explicitly what type to expect, which should resolve the static type checking error.
Select Save Changes.
You can now test to see if this behaviour works.