Displaying just the first X lines of an issues description when sending a custom email through script runner?

Micah Figone June 5, 2014

Is there a way to call issue.description but only show the fist 5 lines of the description?

I am sending a custom email and do not want to display the whole description in it as it might be really long.

5 answers

1 accepted

0 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2014

You want something like this but it's a bit inelegant, also you'd want to show an ellipsis if you are truncating it.

Given a string s:

s.readLines()[0 .. (s.readLines().size() < 5 ? s.readLines().size() - 1 : 4)].join("\n")

There is probably something better in a textutils class.

Mehmet's answer is for velocity templates, whereas you have a GStringTemplate.

0 votes
Mehmet Kazgan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2014
I might be wrong but I think to achieve that you need to write up and save to server, too. However, what you can do is copy the vm to the attachments folder and you still would have a copy there.
0 votes
Mehmet Kazgan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2014

Did you create the custom event and associate with your custom email template you have posted in the server?

You then use script runner to fire that up. One more thing, in order to have those vm's take affect, you need to restart JIRA instance.

Micah Figone June 6, 2014

So I dont want to edit vm templates as those are replaced every upgrade. That is why I am just having it done in the send email post function. If it is not possible there, then that is ok.

0 votes
Mehmet Kazgan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2014

Right. If you look at the link I sent in details- especially the section that has the code:

## setup some additional parameters
$!rendererParams.put("rows", "12")
You can add these parameters to your email template as described here:
You are welcome.
Micah Figone June 6, 2014

haha... thanks... i missed that.

Micah Figone June 6, 2014

Actually. That does not work when sending through script runners send custom email post function.

0 votes
Mehmet Kazgan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2014
Micah Figone June 5, 2014

That is for setting a default description. That is not what i am asking.

Suggest an answer

Log in or Sign up to answer