Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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 Rising Star 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 Rising Star 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 Rising Star 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 Rising Star 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

Atlassian Community Events