Send custom email post function problem rendering Wiki field

Peter Bengov
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.
October 10, 2016

Hey,

I was following Script Runner documentation to take the Description field and render it as Wiki in the email. I've used

{${helper.render(issue.description)}

But I get the following error when I try to preview (or in the log):

2016-10-10 13:18:35,487 http-bio-8080-exec-6919 ERROR Peter.b 798x4556140x3 12f2645 172.29.20.173,0:0:0:0:0:0:0:1 /rest/scriptrunner/latest/canned/com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail/preview [common.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: No such property: helper for class: groovy.lang.Binding
groovy.lang.MissingPropertyException: No such property: helper for class: groovy.lang.Binding

I'm using JIRA 6.3.12 and Script Runner 3.0.16

4 answers

2 votes
Jonny Carter
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.
October 12, 2016

Aha!

The helper variable in the binding is only available in 4.1.3.17 and beyond. For JIRA 7 users, you'll want to use 4.3.7 and beyond.

https://scriptrunner.adaptavist.com/4.1.3.17/jira/builtin-scripts.html#_send_a_custom_email

This was part of the rewrite of the Send Custom Email postfunction we did back in July to add features like this.

Peter Bengov
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.
October 13, 2016

Thanks Jonny for the investigation. 

Any case you are aware of any other function I could use until upgrading to JIRA 7 so that my description field will show more like the original? No wiki formatting, but at least if the description has like few separate lines, I'd like to see this in the email too. Now I get the text from Description field in 1 single like of text).

Example - keep this kind format in the email:

This is the issues.

Please investigate. Further data:

bla

bla

bla

Instead of: This is the issues. Please investigate. Further data: bla bla bla

 

 

Deleted user December 13, 2016

Did you have any workaround for this for JIRA 6.3??

1 vote
Roman Khomych April 13, 2017

Hello,
for Jira 6.3 simply paste the following code in "E-mail template" part:

<%=
def rendererManager = com.atlassian.jira.component.ComponentAccessor.getComponent( com.atlassian.jira.issue.RendererManager.class)
def fieldLayoutItem = com.atlassian.jira.component.ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("description")
def renderer = rendererManager.getRendererForField(fieldLayoutItem)
String desc = renderer.render(issue.description, null)
%>

0 votes
Jonny Carter
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.
October 12, 2016

I'm investigating this now.
I've noticed that in the version-specific documentation, we don't mention the helper:
https://scriptrunner.adaptavist.com/4.1.3.15/jira/builtin-scripts.html#_send_a_custom_email

I'd hazard that's deliberate. It well may be that this only works in JIRA 7. 

0 votes
Peter Bengov
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.
October 10, 2016

Getting the same error with Script Runner 4.1.3.15

Suggest an answer

Log in or Sign up to answer