Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Behaviours on Affects Versions based on a field value

Hi All,

I hope you could help me with this cause i am struggling to get this to work... Also, I am not too clued up on Groovy Scripting so I am going based on researched, etc.

On JIRA Service Desk we have three fields we would like to limit based on a choice made in a dropdown. So the setup we have is something similar to below:

Custom Field Name: Car Brand (This is a single select list field)
AffectsVersion/s (this is the project system field)
Components (this is the project system field)

So, what im after is if the Car Name is set to Ford as an example, then the Affects Versions should only show a list [Fiesta, Figo... etc]. And the same applies to the components: Select Ford and the components would need to be narrowed down to a list [Engine, Gearbox.... etc]

I haver tried using behaviours and adding server side script but im so lost as what is what and how to do etc. I have the code below... but i am not sure if im on the right path


import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.AFFECTED_VERSIONS
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS

def productField = getFieldById(getFieldChanged())
def selectedProduct = productField.getValue() as String
def versionManager = ComponentAccessor.getVersionManager()
def versions = versionManager.getVersions(issueContext.projectObject)
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(

if (selectedProduct == "Ford") {
getFieldById(COMPONENTS).setFieldOptions(["Engine", "Gearbox"])


1 answer

1 accepted

1 vote
Answer accepted

You were very close...

The setFieldOptions needs to set the options using the correct data type.

 getFieldById(AFFECTED_VERSIONS).setFieldOptions(versions.findAll{ in ["Figo","Focus"]})
getFieldById(COMPONENTS).setFieldOptions(components.findAll{ in ["Engine", "Gearbox"]})

Thank you so much for your quick response. I truly appreciate it... However the dropdowns are still showing all the options and not the ones specified as per above.

Below is the screenshot of the actual result:

image.pngAnd below is the configuration of the behaviour:

image.pngSome more of your assistance on this would be greatly appreciated

That is expected behavior. Scriptrunner behaviours are only effective in full edit screen. They can't work for in-line edits.

To get around that, you have to disable inline edits for those fields. Then, when the user attempts inline edit, the edit screen will pop up.

To disable those inline edits, just add those 2 fields to your behaviour configuration (just like you did for Product, but you don't need to change anything else. No serverside script, no read/hide attributes)

This works... Thank you so so so so so much!!!!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

308 views 0 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you