How do I add validation logic and message when selecting a particular component(s)?

I'm developing a workflow validation on the initial transistion "create issue" to check for the component selected. I've tried to use issue.componentObjects*.name.contains('component name') and issue.components*.name.contains('component name'), both dont work. What am I doing wrong?


The main purpose is to provide an error message when the wrong component is selected for a certain condition like by issue type. I can't get pass the component selection. It seems to be not working like sample below.


Script Validator -> Simple scripted validator -> Condition:




2 answers

1 accepted

This widget could not be displayed.

Hi Matheus,

I guess the script could not be simplified...Your suggestion of iterating through the component object works for my validation condition code. I used the Component description to categorize the type to match issue type.

The validation code below returns true when the selected component is allowed for the Issue type.

int allowed_cnt=0;
if (issue.componentObjects.size() >= 1){
 for (int i = 0; i < issue.componentObjects.size(); i++) {
        if(issue.componentObjects.getAt(i)?.getDescription() == "A Component Type" && == 'A Issue Type'){
        } else if(issue.componentObjects.getAt(i)?.getDescription() == "B Component Type" && == 'B Issue Type'){
 if (allowed_cnt >= 1){
 return true;
    } else {
  return false;
} else {
 return false;



This widget could not be displayed.

Try iterating through 



import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue

//Gets the Components List (Collection<ProjectComponent>)
def components = issue.getComponentObjects()

if (components.size() >= 1){
	checkComponents(components, cf)
} else {

def checkComponents(def components, def cf){
	for (int i = 0; i < components.size(); i++) {
        if(components.getAt(i)?.getComponentLead() == "MyComponent"){
        	return false

I have no idea if this will actually work, but it may be worth the shot cheeky


Thanks Matheus for your suggestion...I will give it a try but it seems to be complicated. I'm looking for a simple scripted validator condition code in the workflow validation on create. Also, I'm not checking for the component lead and more on the component name.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

168 views 1 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you