You may have the same behaviour mapped to multiple projects or issue types, and you need to do different things depending on the project or issue type selected.

Your initial instinct may be to add the Issue Type or Project field to the behaviour. However this won’t work in the way that you expect.

Behaviours are mapped to project and/or issue type combinations. So if you change the issue type, the current behaviours are thrown away and new ones are retrieved for the new project/issue type combination, therefore you cannot listen for project and issue type changes.

To explain by way of counter-example. If you changed the issue type to one that had no behaviours, it wouldn’t make sense for the existing behaviour to continue running.

The correct way to handle switching on issue type or project name/key is using an initialiser:

if ( == "Bug") {

if (issueContext.projectObject.key == "FOO") {

Initialisers will run whenever the project or issue type changes, so you can make fields readonly, required etc. there.

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.