Add custom field value to filtersubscription.vm

Ian Lui November 22, 2011

Hi all,

I used to add custom field values in notification email so that users can see the values without login to jira. (Changing issuecreated.vm / issueupdated.vm)

Want to do this for filter subscription as well, however the same method failed to apply to filtersubscription.vm

Any ways I can do this?

Pls find the code below:

#if ($issue.getCustomFieldValue("customfield_11318"))
$stringUtils.leftPad("Market", $padSize): $issue.getCustomFieldValue("customfield_11318")
#end

6 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
jernandez
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 12, 2016

I accessed the custom field value in this template by doing the following (assuming my custom field value is named 'Cost Center' and it's id is 10301):

#set ($cf = $customFieldManager.getCustomFieldObject('customfield_10301'))
#set ($cfValue = $cf.getValue($issue))
cost center: $cfValue

 

 

0 votes
Ian Lui December 4, 2011

Tried your code by no luck.
can you show me the whole source for filtersubscription.vm?

0 votes
MattS
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.
November 30, 2011

Odd. The code I used for this with 4.4 is

#set ($cf = $customFieldManager.getCustomFieldObject('customfield_10380'))
#if ($cf)
  #set ($projectObject = $issue.getProjectObject())
  #set ($issueTypeObject = $issue.getIssueTypeObject())
  #set ( $idArray = [$issueTypeObject.id] )

  #if ( $cf.isInScope($projectObject, $idArray) )
    #set ($currValue = $cf.getValue($issue))
    Checking that $cf.name has a value of $currValue
  #end
#end

0 votes
Ian Lui November 30, 2011

I have tried to modify inside the for-loop. It works for the attribute above but not CUSTOM FIELD

0 votes
MattS
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.
November 30, 2011

That's because there is likely no $issue object in the top-level Velocity context. A filter subscription will contain a set of issues so this should work inside the loop

#foreach ($issue in $issues)
${StringUtils.rightPad($issue.getKey(), 12)}${issue.getSummary()}
${StringUtils.rightPad("", 12)}${baseurl}/browse/${issue.getKey()}
#end

0 votes
Florin Haszler _Alten Kepler_ November 27, 2011

Have a look of another way of sending notifications from JIRA and use whatever custom fields you want with our plugin JJUPIN: http://confluence.kepler-rominfo.com/display/JJUP14/Email+Templates

Plugin page on PAC: https://plugins.atlassian.com/plugin/details/43318

You may evaluate it and fine probably some more interesting features.

Good luck!

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events