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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Groovy expression using "contains" comparing with a variable Edited


I am using a ScriptRunner Script Listener utilizing

(issue.getSummary().contains("Escalation EMEA Project XY"))

which works pretty well.

I have an use case where I'd like to replace the predefined string with "contains" using a variable. Is this possible from Groovy scripts?


Where "projectEscalation" is a defined variable (basically working!) - I had no success.

Is there anything I am missing?

Basically I want to do further checks if the summary matches a specific string and if this is the case some other logics apply (already implemented and works).




2 answers

1 accepted

0 votes
Answer accepted

This is just about using variables in groovy.  Try replacing

(issue.getSummary().contains("Escalation EMEA Project XY"))


def thingy = "Escalation EMEA Project XY"

Note that in your question, you had also swapped "contains" for an exact match of "equals"

Thanks! I think I got an idea how it is supposed to work. While "equals" seems to work "contains" throws an error.


[Static type checking] - Cannot find matching method
Please check if the declared type is right and if the method exists.
Possible solutions: contain(java.lang.CharSequence),
contains(java.lang.CharSequence), toString(), toString(), toString(), notify() @ line 19, column 4


Where the variables are defined as follows:

def ticketReference = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10302")
def ticketReferenceValue = issue.getCustomFieldValue(ticketReference)

A typical content of the customfield is something like
I am unsure if the content is the reason for the error message (especially for the brackets or the hash sign).

Is there maybe an easy way around to fix it? That would be fabulous. Otherwise I'd consider to match agains at least a static string.

It is all solved now. Please ignore my previous message.

The last step missing was to use String instead of def.


Thanks to Nic for the good hint that pointed to the right direction.
I will mark the question as answered now.

Best regards,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

105 views 1 11
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you