Scripted Conditions
The following script is a collection of example conditions that can be used with Behaviours. These conditions demonstrate various ways to dynamically control field properties based on different criteria such as user roles, custom field values, and workflow states. To use one of these conditions in a Behaviour script, select the relevant part of the code and adapt it to your specific needs.
Further details on the following API can be found on the Behaviours API Quick Reference page.
Line 9: If the current user is the reporter AND the current user is the current assignee make the changed field hidden, else shown
Line 15: If the current user in group 'jira-administrators' allow the inline edit of the changed field
Line 23: If the current user is 'luke' or the current user in the project role 'Developers' make the changed field read-only and show an error message, else clear the error and make the field editable again
Line 31: If the current user is Project Lead add a description at the changed field, else clear the description
Line 37: If the current user is in the user custom field value add a default value in the description
Line 44: If the current user is in the group custom field value then make the changed field required, else optional.
Line 52: If workflow Action is 'Start Progress' or workflow Step is 'Done' then make the changed field required, else optional.
Examples
Check out the following examples to see how conditions could be used in a Behaviour:
Non-scripted conditions
Behaviours allow you to add conditions without writing code. When adding a field to a behaviour, you can select Add new condition. Here you can choose whether the behaviour will run or not when the condition you set is true. You can set then a condition to further define the field you are configuring.