Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Script runner "Send Custom Email" sends email with html tags in description field content

Aravindi Amarasinghe August 16, 2018

Hi All, 

I am trying to send the email using Script runner Send Custom Email option. 

My code is as follows.  I am using "Plain Text" and this sends email with HTML tags. 

Environment: <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Environment')).toString()) %>
Description: $issue.description

 

Changing the Description render from JEditor to Default solves the problem. But it is not supporting service desk requests. 

JIRA: 7.3.8

Scriptrunner: 5.0.11

Can somebody help me with this? 

Thank you!

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Jenna Davis
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.
August 20, 2018

Hello, 

Could you send an example of what email you receive and a screenshot of the settings you are using on Send Custom Email? Then I'll be able to get more context into what exactly you're doing and what might be going wrong. :)

 

Regards,

Jenna

Aravindi Amarasinghe August 20, 2018

Hi @Jenna Davis

Settings are as follows

image.png

Preview is as follows. 

image.png

Jenna Davis
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.
August 21, 2018

Could you please try changing the Email format from "Plain text" to "HTML"?

I think you might be pulling in html tags from your issue description, changing this setting should let them get interpreted instead of being printed out in the email's body. To check this, you could add a logging statement to see exactly what you're getting when you call '$issue.description". Something like this - 

log.debug(issue.description)

Let me know if this helps!

Regards,

Jenna

Aravindi Amarasinghe August 21, 2018

Hi @Jenna Davis

Thanks for the suggestion. 

Changing the Email format to HTML and some </br> notations did the job. And didn't want to change description line. 

The following Production SPM has been actioned today. 
</br>
Service Desk ticket: $issue.key
</br>
SPM X-Ref - Test : <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('SPM X-Refs - Test')).toString()) %>
</br>
SPM X-Ref - Prod : <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('SPM X-Refs - Prod')).toString()) %>
</br>
Keyed by: <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Keyed by')).toString()) %>
</br>
Reviewed by (Peer): <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Peer-Reviewer')).toString()) %>
</br>
Reviewed by (client): <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Reviewed by Client')).toString()) %>
</br>
To the Global Release Team: The SPM has also been applied to the following environments
</br>
Environment: <% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Environment')).toString()) %>
</br>
Description: $issue.description
</br>
Jenna Davis
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.
August 27, 2018

Great! Glad that worked for you. 

If you're satisfied with my answer could you please accept it? This helps to let others know how to fix this issue should they encounter it. :)

Also, please do let me know if you have any other questions. 

Jenna 

Aasha May 18, 2020

@Jenna Davis -- I need a favour one of my client is need to see only Active sprint for a task associated in structure. How can i achieve that. We need to see only active sprint task in stucture- this is a 3rd party add-on.

Can you help?

TAGS
AUG Leaders

Atlassian Community Events