Hello I am using script runner add-on and I have created a script listener to send a custom email when ever there is a comment on an issue.
I only want to send the email if the comment is a public comment (not internal). Below is my email template with an attempt that does not work (getRoleLevelId returns null always):
<html>
<body>
<% def commentManager = componentManager.getCommentManager()
def comments = commentManager.getComments(issue);
// if the comment is internal dont print the reporter and request participants
if(comments.last().getRoleLevelId() == 10101){
out << "internal comment"
}
// else print the external customer who may have recieved the comments
else {
out << "People on the ticket who recieved an email of the comment:<br>"
out << "To:<br>"
out << "<b>" + issue.getReporterUser().getEmailAddress() + "</b><br>"
out << "CCed:<br><b>"
def cf = componentManager.getCustomFieldManager().getCustomFieldObjectByName("Request participants")
if(cf){
def cfVal = issue.getCustomFieldValue(cf)
if(cfVal){
def size = cfVal.size()
if(size){
for( int i = 0; i < size; i++)
out << cfVal.get(i).getEmailAddress() + "<br>"
}
}
}
}
%>
</b><br>
Current Listed Company:<br>
<b><% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Company")) %></b><br>
<br>Current Listed Location:<br>
<b><% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Location")) %></b><br>
<br>
Link to the ticket:<br>
<a href=https://supportdesk.disti.com/browse/${issue.key}>${issue.key}</a><br>
<br>
<span style="font-size:26px"><b>Latest Comment:</b></span><br>
<% if (lastComment)
out << lastComment
%>
<span style="font-size:26px"><b>Prior Comment:</b></span><br>
<% if (latestPriorComment)
out << latestPriorComment
%>
<span style="font-size:26px"><b>Description:</b></span><br>
<pre>${issue.description}</pre>
</body>
</html>
How can I tell if the last comment on an issue is internal or not?