Send custom email post function problem rendering Wiki field

Peter Bengov Community Champion Oct 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

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 Community Champion Oct 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

 

 

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

0 vote
Peter Bengov Community Champion Oct 10, 2016

Getting the same error with Script Runner 4.1.3.15

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. 

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)
%>

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

496 views 2 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you