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 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

91 views 0 1
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