Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

List watchers on out going emails

Leon Wright May 30, 2012

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

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Leon Wright February 10, 2014

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

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 30, 2012

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.

Leon Wright May 31, 2012

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!

Leon Wright May 31, 2012

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

http://docs.atlassian.com/jira/4.4/com/atlassian/jira/component/ComponentAccessor.html#getIssueManager%28%29

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!

TAGS
AUG Leaders

Atlassian Community Events