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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

How to fetch the data of component using behaviour script runner

As i used validation on component (to select/restrict  to   one field only )



1st i tried this 

import com.onresolve.jira.groovy.user.FieldBehaviours
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.component.ProjectComponent

def component = getFieldById('components-textarea')
List <ProjectComponent> result = component.getFormValue() as List

if(result.size() >1)

component .setError("Only one Component is allowed")


else {




 2 ] I tried  to get atleast size of selected element 


def c = ComponentAccessor.componentClassManager.getMetaPropertyValues()


def component = getFieldById('components-textarea')
component.setHelpText("----->>Multi Select Field is set to Support " + c.size())




Help me to put validation on component field  . My Requirement is to select only one field from System component field .


2 answers

0 votes
Hana Kučerová Community Leader Nov 09, 2020

Hi @Nishant Paraskar ,

you are using incorrect id for components field, it should be "components" instead of "components-textarea".

Something like this should work:

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FormField
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS

FormField componentsField = getFieldById(COMPONENTS)
List<ProjectComponent> components = componentsField.getValue() as List

if (components.size() > 1) {
componentsField.setError("Only one Component is allowed")
} else {

Excellent! Thanks

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events