Sending Custom Email with WIKI style rendering

Hello, 

Im currently doing a project for outbound emails using JIRA 6.3.3 Scriptrunner 3.0.5.

 

This is the code i currently have:

 

<%
def userKey = "customer.care"
def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
def lastCommentFromUser = comments?.findAll {it.authorApplicationUser.key == userKey}
def issueDesc = issue.description
def emailAdr = issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObject(10301))
def emailSubj = issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObject(10805))
def emailBody = issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObject(11374))
def emailInfo = "<br/><br/>From: " << emailAdr << "<br/>" << "Sent: " << "$lastCommentFromUser.created" << "<br/>" << "To: " << "ACNVFEscalations@acnpacific.com.au" << "<br/>" << "Subject: " << emailSubj << "<br/><br/>"
                                           
if (lastCommentFromUser)
    lastCommentFromUser = out << emailBody.replaceAll("\\n","<br/>") << "\n\n" << emailInfo << "\n\n" << lastCommentFromUser.last().body.replaceAll("\n","<br>") 
    else if (issueDesc)
        lastCommentFromUser = out << emailBody.replaceAll("\\n","<br/>") << "\n\n" << "------Original Message------" << "\n\n" << issueDesc.replaceAll("\\n","<br/>")
        else lastCommentFromUser = out << emailBody.replaceAll("\\n","<br/>")
%>

 

When sending email with HTML text setting (or plain text), the comments with bold are rendered as *text* instead of the text actually being bold. 

 

Is there a way to email out the custom field and comment converting wiki to HTML?

 

Many thanks, 
pon 

1 answer

1 accepted

This widget could not be displayed.
Steven Behnke Community Champion Dec 13, 2016

I used this code for my Description field, which handles everything except attachments.

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

Thanks Steve, also works with customfields smile 

Cheers, 

Pon

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

189 views 3 0
Join discussion

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