Hi,
I'm sure I'll figure this out eventually, but I am having trouble pulling the list of current watchers of an issue and displaying them in an outgoing email. I've done bits and pieces with adding custom fields successfully, but that was quite some time ago!
So far I've read the API, but I've not reached the "aha" moment yet. This is what I've come up with:
<table cellpadding="2" cellspacing="0" border="0" width="100%" align="center"> <tr> <td style="color:#fff;background-color:#bbb;width:1%;white-space:nowrap;text-align:center;font-weight:bold;"> #text ("Watchers") </td> </tr> </table> <table cellpadding="2" cellspacing="0" border="0" width="100%"> <tr> <td bgcolor="#ffffff" valign="top"> getIssueWatchers($issue.getId()) </td> </tr> </table>
I probably need to do some more learning/understaind, but any pointers would be appreciated.
Leon
Community moderators have prevented the ability to post new answers.
We already utilise a custom field for adding watchers. Which we can query to get the current watchers out of. Answer found here:
https://answers.atlassian.com/questions/74785/display-watchers-in-email-notification
Your "getIssueWatchers" line is not a call to anything. Velocity templates are parsed when needed and for plain text (including all the html you've got in there) they just dump it straight into the output. If they spot something with a # on the front, then they see that as a Velocity directive or command (#if, #else, #foreach, #end and so on) and then things starting with $ are either variables/objects or calls to the Java behind them.
So, to start with, you'd actually want $getIssueWatchers($issue.getId()) but that assumes that getIssueWatchers is in the "velocity context" - i.e. the java has said to Velocity "run now, here's some objects you'll need, like the $issue"
I'm not sure what is in the velocity context here, or where you got the pointer to getIssueWatchers from in the API, but I suspect you'll probably need something more like $issueManager.getIssueWatchers - I doubt getIssueWatchers is dropped into the context as a simple variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are quite correct, somehow I'd dropped the $ from the code I copied in (probably when I removed a bunch of other things I was testing). Looking at the velocity page it doesn't look like there is anything related to the issueManager:
https://developer.atlassian.com/display/JIRADEV/Velocity+Context+for+Email+Templates
I was kinda hoping that the watchers were an attribute of the $issue object in the template, $issue.getId() actually returns the issue number correctly. Time for some more reading!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seeing that I also left out a bit of key information, this system is running 4.3.3, looking at the API doco, it doesn't look like getIssueManager is availble until 4.4.
http://docs.atlassian.com/jira/4.3/com/atlassian/jira/component/ComponentAccessor.html
I'm not entirely sure how I'd access it in the context of an email (of if it's even available), but presumably something like below:
$ComponentManager.getInstance().getIssueManager().getIssueWatchers($issue.getId)
Thanks for your help!
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.