Hello,
I would like to add custom field to JIRA 5.1 html notifications e-mail. I found that I need to modify velocity templates , e.g. issuecreated.vm. In that file i found references to the include folder to specify which fields to include.
Could you please advise how to make .vm file for custom field to include it into issuecreated.vm?
Thank you in advance.
Regards, Georgiy
hi
lets assume your customfield has id 11800
in your your_new.vm file put this info:
#disable_html_escaping() #if ($issue.getCustomFieldValue("customfield_11800")) <tr valign="top"> <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:${textSubtleColour};">#text("NAME OF YOUR FIELD"):</strong> </td> <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;"> $issue.getCustomFieldValue("customfield_11800") </td> #end </tr>
then include it in issuecreated.vm like this:
#if ($issue.getCustomFieldValue("customfield_11800")) $stringUtils.leftPad($issue.getCustomField("customfield_11800").name, $padSize): $issue.getCustomFieldValue("customfield_11800") #end
this will make your field appear in emails only if it has values...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I made new.vm file as you advised and then included it into issuecreated.vm file as
#parse("templates/email/html/includes/fields/new.vm")
and it works as needed :)
Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
glad i could help...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shouldn't the closing</
tr
>
tag be positioned before the #end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oh you're right. just for optical satisfaction...but it works like this (i took it from current working instance)
ok i just re-checked with an out-of-the-box file that came with jira..
cat atlassian-jira/WEB-INF/classes/templates/email/html/includes/fields/reporter.vm
#disable_html_escaping() <tr valign="top"> <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:${textSubtleColour};">#text("issue.field.reporter"):</strong> </td> <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;"> #if ($issue.reporterId) #authorlinkkey($issue.reporterId $linkstyle) #else #text("common.concepts.no.reporter") #end </td> </tr>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am encountering a problem with including custom fields in e-mail templates. The template does not appear to evaluate the getCustomFieldValue it simply output the raw code, see below. The custom field has a value for the issue I am sending the e-mail from. Is there a setting or other action needed to get the custom fields to work or is my code wrong? Any advice is appreciated. I am running JIRA 6.3.15 Code in template file: #if ($issue.getCustomFieldValue("customfield_10011")) $stringUtils.leftPad($issue.getCustomFieldObjectByName("customfield_10011").name, $padSize): $issue.getCustomFieldValue("customfield_10011") #end Participant: $issue.getCustomFieldValue("customfield_10011") Result in e-mail: Participant: $issue.getCustomFieldValue("customfield_10011")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Faysal,
As you mentioned first, In which folder could i past that code can you clarify that i need priority_Hcp customfield is to add in email.
Thank you,
Venkatesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can create your own vm or templates,you can refer custom fields as below.
#set($fieldname=$customFieldManager.getCustomFieldObject("customfield_11100"))
$issue.getCustomFieldValue($fieldname)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is the following syntax OK?
#set($cf_downtime=$customFieldManager.getCustomFieldObjectsByName("Downtime").next()) $issue.getCustomFieldValue($cf_downtime)
Basically what I'm asking is, can we use getCustomFieldObjectsByName() function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.