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

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;



1 votes

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,897 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot