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>

0 vote

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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

207 views 2 11
Read article

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