JIRA & Velocity Templates

Hi All,

I have attached a template (.txt file) I’ll be using with Jeti - But I hope you guys can understand my logic even if you do not use JETI.

I will be using one template and on transition this template will be used but based on #else/elseif statements..

I have gotten as far to be able to use the email button feature for manual AD-HOC emails sent from within an issue using a section of the template, and as you can see others are based on IssueTypes and field values.. Which work perfectly.

However I have become stuck where I want to use a status to trigger a part of the template but this then triggers other parts of the template.. So in effect I get two emails.. which I don’t want.

So I thought about creating a custom field that on transition this field is updated with a value, which I have done, but I now want the template to include this custom field data to trigger a section of the template.

I have become so focused on this that I have completely got myself lost..

I have 3 custom field values;

Custom Field ID: 10700

1. ReStart

2. Resolve

3. Further Assessment

4. no value/emtpy/none (which ever works)

I have tried to replicate what I have done already but I have failed. As you are most likely more skilled than I, can you see just from a quick glimpse how or where I should place this extra content. Or is there a way that events can be included from within the template?

Any help or guidance or any documentation that I may not have uncovered would be very grateful.

Many thanks (Test Template.txt)

6 answers

These templates will be sent to the public, there is no sensitive data within.

(Test Template v2.txt)

Managed to resolve with the following... Well... So to speak...

I still end up with some data included from other templates.

But the actual sections send upon transition using the correct fields.. Though I will attempt to maybe purge fields were possible to see if this resolves.

Attached revised .txt.

If anyone can see where an improvement can be made pleae feel free to let me know. Any help at all is much appreciated.

My mistake.. I left test data in the template :-)

You could try to split business logic from HTML using macros: http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#velocimacros

// HTML templates
Dear Sir/Madam</br>
<b>Re: $!issue.key $!issue.summary</b> received on <b>$dateformatter.formatDMYHMS($issue.getCreated())</b></br>
Thank you for contacting the European Medicines Agency.</br>
// add other macros printRestart, printResolve, printOther
// logic
#if ($!mailBody.length() > 0)
  #set($intermediateStatus = $!jetiFieldRenderer.renderCustomField($issue, 'customfield_10700'))
  #if($intermediateStatus == "ReStart") 
  #elseif( $intermediateStatus == "Resolve")

This way you can understand better how your template will work.

Thanks, Remiguisz

I will look at this method, much appreciated

I have finally cracked it with my method, but I'll look at definitley look at making it more meaningful.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

967 views 3 9
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