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 script for concatenating the summary and created date of a ticket?

Hi again everyone,

I'm a new user of groovy, and I'm trying to learn its ins and outs but even this simple task has me stumped... I'm trying to concatenate a subtask's summary with it's created date.


From what I've read in Jira documentation / groovy documentation I'm using the following:

String summary = "issue.get("summary")" + " - " + "issue.get("created")


Can someone please help me understand what I'm doing wrong?



2 answers

0 votes
Payne Community Leader Mar 12, 2020

Hey Michael,

I don't know that there is a get(field) method like you're using, but there are ones such as getSummary(), getCreated(), etc. (which can be shortened to issue.summary and issue.created, etc.).

You've also got your double quotes a bit mixed up. Try the following, and see for more information about what you can do.

String newSummary = issue.summary + " - " + issue.created

That'll get the string you seek, and then you'll then need to update your issue with the revised summary.

Hi again @Payne

How would the code look for updating the issue? and would it come before or after I input the:

String newSummary = issue.summary + " - " + issue.created

Hi again @Payne  - I've tried the above string, and although it works within the script editor, it doesn't work when I go through the actual workflow. Is there something I need to input before the:

String newSummary = issue.summary + " - " + issue.created



Payne Community Leader Mar 18, 2020

It depends upon where you are; if you're working with a ScriptRunner post function, for instance, issue is pre-defined. What exactly are you doing, and what do you mean by it doesn't work?

Hi again @Payne 

We are using a groovy script listener via the "workflow magic box" plugin in order to append the creation date to all parent/subtask tickets for our Jira data center instance.

When I input the exact code above into the groovy script editor, it works, but not when we try to trigger the code via a "issue.created" event, it doesn't append the creation date. (see screenshot)

screenshot of script running without errors.png


Payne Community Leader Mar 18, 2020

Ah, OK. You're merely assigning the concatenated string to a variable, but you're not updating the issue. You need to do something like:

issue.summary = newSummary

That may work, but if not, you need to do something like that. That's what I said in my original response: That'll get the string you seek, and then you'll then need to update your issue with the revised summary.

Hi again @Payne

So for example, if I want to concatenate the entered summary with the creation date of the issue, I'd need to type in the following:

issue.summary = issue.summary + " - " + issue.created

 Is that correct?

Thanks again,

Payne Community Leader Mar 18, 2020

Try it. I'm not sure if it's that simple. If not, you'll need to explore how to update an issue with your add-on.

Hi again @Payne

I'll probably have to ask the plugin people for help, as that didn't seem to work either :(.

Thanks for the help!


0 votes

HI @Michael 

Type this code in your console and hit run.

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("SD-18") //Change Issue Key

return issue.summary + " - " + issue.created

Of course change the Issue key.

I hope it will help you.


Hi again @Ravi Sagar _Sparxsys_ ,

That code works! But is there a way for it to auto-pull in the current issue ID where I had to manually input one? maybe something like getIssueID()?



Hi @Michael 

The code I shared works in the Console where you can test scripts or run ad-hoc scripts. If you use this script in let us say a Script field or listener. You will have Issue ID already available without declaring it.


Hi again @Ravi Sagar _Sparxsys_ ,

Just for clarification, what would the code look like that I would be inputting into a groovy script listener?

From what I'm seeing above within your code, the issue key would need to be changed every time a new issue was created.

Suggest an answer

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

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

524 views 1 9
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