How to Write a Groovy Expression that Specifies a Component?

I'm trying to set a watcher field based on project component specific condition post-script called "Set Field Value to Constant or Groovy expression", 

Setting the Watcher function works without the component condition but fails when I set a condition. 

I tried:

issue.get("components") == "13098"

issue.get("components") == "Component Name"

issueObject.get("components") == "13098"

issueObject.get("components") == "Component Name"

This is similar to https://answers.atlassian.com/questions/285260 but Component instead of custom field. 

2 answers

1 accepted

1 vote

Checkout Jamie's answer here.

Hi Jobin,

Thanks for your reply!

Tried it as "issue.components*.name.contains('Component Name')

Screen Shot 2014-09-25 at 5.52.29 PM.png

got this error in logs:

[jmwe.plugins.functions.SetFieldValueFunction] Error while executing SetFieldValueFunction: java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerAdapter cannot be cast to java.lang.Boolean
java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerAdapter cannot be cast to java.lang.Boolean

You might want to post the full script. I am not sure where logging comes in here!

Henning Tietgens Community Champion Sep 25, 2014

Reading the comment below the box I think you have to use issueObject instead of issue. So try issueObject.components*.name.contains('Component Name')

issueObject.components*.name.contains('Component Name') and issue.components*.name.contains('Component Name') both works. The culprit was "log" =( Thanks everyone!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

809 views 2 19
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