Add Workflow Buttons to Velocity Email Templates?

Does anyone have any idea how to do this?

We'd like it if there were workflow-buttons included in an email template. Wouldn't it be great if I could "Resolve" or "Open" an issue directly from the HTML email I receive from JIRA?

Ed

2 answers

1 accepted

Thanks Fabio.

I'm not adept enough with the Apache Velocity to do like you suggested, but I went ahead and "hard coded" my results.

I use the file at WEB-INF\classes\templates\email\html\includes\patterns\comment-action.vm -- this is the piece that adds the Comment link at the bottom of almost all outgoing JIRA notifications. I made some "if - elseif - end" loops to add the links based on the Status Name:

#disable_html_escaping()

#set ($commentActionText = "${i18n.getText('jira.mentions.email.comment.add')}")

#* @vtlvariable name="attachmentsManager" type="com.atlassian.jira.mail.util.MailAttachmentsManager" *#

<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%">

    <tr>

        <td id="actions-pattern-container" valign="middle">

            <table align="left">

                <tr>

                    <td class="actions-pattern-action-icon-container">

                        Status: ${issue.getStatusObject().getSimpleStatus().getName()} -  

                    </td>

#if(${issue.getStatusObject().getSimpleStatus().getName()} == "New")

<td class="actions-pattern-action-icon-container">

<a href="${baseurl}/secure/WorkflowUIDispatcher.jspa?id=${issue.getId()}&action=4" target="_blank">Acknowledge</a> | 

</td>

<td class="actions-pattern-action-icon-container">

<a href="${baseurl}/secure/WorkflowUIDispatcher.jspa?id=${issue.getId()}&action=1101" target="_blank">Stall</a> | 

</td>

<td class="actions-pattern-action-icon-container">

<a href="${baseurl}/secure/WorkflowUIDispatcher.jspa?id=${issue.getId()}&action=5" target="_blank">Resolve</a> | 

</td>

<td class="actions-pattern-action-icon-container">

<a href="${baseurl}/secure/WorkflowUIDispatcher.jspa?id=${issue.getId()}&action=1091" target="_blank">Reject</a> | 

</td>

#elseif(${issue.getStatusObject().getSimpleStatus().getName()} == "Stalled")

<td class="actions-pattern-action-icon-container">

<a href="${baseurl}/secure/WorkflowUIDispatcher.jspa?id=${issue.getId()}&action=1121" target="_blank">Resume</a> | 

</td>

<td class="actions-pattern-action-icon-container">

<a href="${baseurl}/secure/WorkflowUIDispatcher.jspa?id=${issue.getId()}&action=5" target="_blank">Resolve</a> | 

</td>

 #end

                    <td class="actions-pattern-action-text-container">

<a href="${baseurl}/browse/${issue.getKey()}#add-comment" target="_blank"><img class="actions-pattern-action-icon-image" src="$attachmentsManager.getImageUrl("/images/mail/comment-icon.png")" alt="$commentActionText" title="$commentActionText" height="16" width="16" border="0" />Comment</a>

                    </td>

                </tr>

            </table>

        </td>

    </tr>

</table>

Hi Edwin,

I did it in the past, you can update email template and embed in a button "resolved" or whatever you want. Each button should run a function that call the following REST service

/rest/api/2/issue/{issueIdOrKey}/transitions

Here Rest Api documentation : https://docs.atlassian.com/software/jira/docs/api/REST/latest/

Here, email template update way : https://confluence.atlassian.com/display/JIRA/Customizing+Email+Content

Hope this helps,

Fabio

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,075 views 13 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot