Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I get the list of component/s when utilizing ScriptRunner?

My team wants to add a custom field that is read only until specific Components are selected. I have created a Behaviour on the field already. Currently the field is read only. I would like to create a custom script that can change the custom field to "writable" once the"Sys Admin" or "SysAdmin" component's are chosen. I've been banging my head on this for the last two days and I just feel lost now. Getting the list for the components seems to be the hardest part. Please help me out. (We have the server addition)

1 answer

1 accepted

0 votes
Answer accepted
Leo Community Leader Dec 09, 2019 • edited

Hi @Terrell 

I'm not a efficient coder, though below snippet will do the trick for you

import com.atlassian.jira.bc.project.component.ProjectComponent

def componentFF = getFieldById(fieldChanged)
def field = getFieldByName("Field name to be read-only")


List <ProjectComponent> components = componentFF.getValue() as List
def isThere = false

for(c in components){
if(c.getName() == "Sys Admin" || c.getName() == "SysAdmin"){
isThere = true


Note: this behaviour should be added for Component/s field not for Custom field



Hey Leo, thanks for taking the time to reach out... I've implemented the code example you suggested and I'm not getting any errors but I am also not getting any results. I have the code executing as a server-side script. I am expecting the issue to attempt submission, but fail because I have set the "sysAdminCF" field as required. Is the logic incorrect?

Also, I'm not sure if I am using the correct component id as there are multiple id's within the man Div.2019-12-10_11-11-38.png2019-12-10_11-27-54.png

Leo Community Leader Dec 10, 2019

I'm not sure whether "components-textarea" is the correct one or not

you can use

def component = getFieldById(fieldChanged)

Ahh yes! I wasn't sure if "fieldChanged" was just used as a placeholder for the id of the component field or what. That explains why I wasn't getting any results. Thanks for your help, it works like a charm!

Suggest an answer

Log in or Sign up to answer

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