JIRA & Velocity Templates

Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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

0 votes
Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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

0 votes
Remigiusz Jackowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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.

0 votes
Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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

0 votes
Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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.

0 votes
Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

(Test Template v2.txt)

0 votes
Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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

Suggest an answer

Log in or Sign up to answer