Hi,
in this answer, it is shown how to include the content of a custom field in the custom email template of the scriptrunner post function. So in the custom email template I'm now using
<% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MyField")) %>
However, MyField is a custom field that uses a wiki style renderer and in the e-mail (which is send as HTML), it just displays the text of the field without any formatting and without any linebreaks.
Is there a way to nicely format a the text from the custom field in the e-mail?
Cheers, Thomas
Hi @Thomas König ,
I resolved the same task with IssueRenderContext -
Condition and Configuration:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.renderer.IssueRenderContext
def rendererManager = ComponentAccessor.getComponent(com.atlassian.jira.issue.RendererManager.class)
def wikiRenderer = rendererManager.getRendererForType("atlassian-wiki-renderer")
def renderContext = new IssueRenderContext(issue)
def myCf = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)?.findByName("my_cf")
//Don't forget to map rendered value:
config.renderedMyCf = wikiRenderer.render(issue.getCustomFieldValue(myCf) as String, renderContext)
Email Template:
${renderedMyCf}
Good luck!
Hi Andrey...looking for some feedback on this. I had used this same logic to render my description field a while back and it no longer works. So I tried it with your solution to render a custom field and that is not working either.
Any insight? It's throwing an error saying the variable [renderedMyCf] is undeclared
And of course right after I posted this I actually checked the output via SR preview and it is rendering. Do you know why it's showing the red X though?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have not found a proper way to do this, yet. However, using the Automation for Jira plugin to send the e-mails allows to at least keep the line breaks from the custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think you can keep the visual form of a customfield since email are not using the same style display with Jira.
I'll keep an eye on this topic in case i'm wrong but I strongly doubt on this !
Keep having fun with Jira !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.