Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can ScriptRunner or PowerScripts parse the Description field?

Jon Jones October 23, 2018

We would like to add Component/s to a ticket, based on key words that may be mentioned in the Description field. Are there any resources to learn about what the syntax is for Groovy to parse the Description field and look for certain words, then add those Component/s via Listener or some other means?

1 answer

0 votes
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 23, 2018

Hi @Jon Jones

Groovy is a script language based on Java.

Also, there are plenty example of how to use groovy over the internet (just try to google). 

Eventually the value returned in script for field "Description" is a long String, so all you need is to parse a string and look for the value you want.

Jon Jones October 24, 2018

Thank you @Nir Haimov! Unfortunately my google search fu isn't up to snuff because I did try to search for specific examples in Groovy, and even consulted the official Groovy reference, but because it's not specific to Jira and I'm a novice with this kind of scripting, it left me a bit lost. I've seen lots of code examples in ScriptRunner and for Groovy that call classes (or whatever "import com.atassian.blah" etc etc are called), so there must be a reference, but I am baffled that Atlassian doesn't seem to have a reference listing for all those kinds of things.

I'm glad to know that it should theoretically be possible, though. Thank you for your answer!

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2018

Hi @Jon Jones

It should be something like this:

/* get the description */
def descriptionValue = issue.getDescription()

/* Check if your description contains the word you want
"valid" will be true if the word exist or false if the word does not exist */
def valid = descriptionValue.contains("the word you want to check")

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events