Make a field read-only except for a certain role

Now we’ll make the "Environment" field writable only if the user is in the project administrator role (for no particular reason).

Add the Environment field to your behaviour, and set it to be read-only. Now, add a condition to this rule. Click the Add Condition link, and choose the Except radio button, then select the Administrators from the Project Role dropdown. The behaviour should now look like this:

img1E

So to translate this, the Environment field will be read-only, except when the current user is in the project administrators role for this project.

The conditions work like this. If any of the When conditions are true, the field behaviour will apply. If there are except conditions, and if any of those are true, the behaviour will not apply.

It’s possible to add the same field twice to a behaviour. In fact, to continue this example, if you wanted the Environmenet to be mandatory for project admins, and read-only for everyone else, you would have to add it twice (although you might be better using a script instead).

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.