Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Retaining the format of the field value in the custom email notification through post function.

Pooja Singh November 19, 2018

Hello,

I have written a post function which will fire an email to the designated vendor whenever the ticket reaches on Waiting for Vendor stage. The email body should contain the fields visible on the issue.

I am able fetch all the fields on to the email body. But few fields like Description and Comment have values with some  formatting.  We need the formatting to be the same when fetching the data on the email as well.

Is there a way that this can be achieved?

I have attached screenshots for reference.

Thanks in advance.

Regards,

Pooja

email_view.pngticket_view.png

1 answer

1 accepted

1 vote
Answer accepted
Carmen Creswell [Adaptavist]
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.
December 13, 2018

Hi Pooja! 

You can get the description to show up correctly by using the email template in Plain text format instead of HTML and using $issue.description. 

Pooja Singh February 18, 2019

Hello @Carmen Creswell [Adaptavist] ,

Thank you for your response.

I had tried keeping both Text as well as Plain text format.

I was able to resolve this issue by rendering the description field.

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

Doing this, helped me get the exact format of the Description field in my email notification.

Same code can be applied for getting Comments field's format.

 Regards,

Pooja

Suggest an answer

Log in or Sign up to answer