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
#macro(printHeader)
Dear Sir/Madam</br>
</br>ADHOC</br>
<b>Re: $!issue.key $!issue.summary</b> received on <b>$dateformatter.formatDMYHMS($issue.getCreated())</b></br>
</br>
Thank you for contacting the European Medicines Agency.</br>
</br>
...
#end
// add other macros printRestart, printResolve, printOther
// logic
#if ($!mailBody.length() > 0)
  #printHeader()
#else
  #set($intermediateStatus = $!jetiFieldRenderer.renderCustomField($issue, 'customfield_10700'))
  #if($intermediateStatus == "ReStart") 
    #printRestart()
  #elseif( $intermediateStatus == "Resolve")
    #printResolve()
  #else
    #printOther()
  #endif
#end

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.

Thanks


Darren

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,198 views 13 19
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