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:

field read only

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).

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

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

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.