Forums

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

Set summary field with substring of parent issue's summary

Ian Balas July 12, 2021

Hi all,

I'm currently working on a JMWE post-function to auto-populate child issues upon creating an epic. I have a text template pre-populated from a scriptrunner behavior in the summary field of the epic that reads "[Property Name] - Checklist". The user is to fill out the property name in the brackets, fill out the rest of the form and create the epic. For the child issues created in the post-functions, I want the "[Property Name]" substring of the epic's summary to populate to the child issues' summary so that it would set to "[Property Name] - Team Information"..and the next child issue's summary would be "[Property Name] - System Overview", and so on.

I know I could easily reference the entire summary and copy that over to the child issue summaries like "[Property Name] - Checklist - Team Information" and "[Property Name] - Checklist - System Overview"...but if I can, I would want to avoid concatenating the Checklist part of the parent's summary, if at all possible.

 

Screen Shot 2021-07-12 at 1.56.35 PM.png

 

So I thought setting the summary to a groovy constant like ${issue.summary.substringBefore("-")} - Team Information would work..but unfortunately it doesn't. if I can't reference that substring method to concat part of the parent's summary, is there another way to do it? (Or did I do it incorrectly?)

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
July 12, 2021

Hi @Ian Balas ,

the problem is, there is no such thing as a substringBefore() method on String objects, neither in Java nor Groovy.

There are plenty of alternatives though. The simplest is:

issue.summary.split("-")[0]

Best,

David 

Ian Balas July 13, 2021

@David Fischer 

This works perfectly. Thank you!

Suggest an answer

Log in or Sign up to answer