I'm using Jamie Echlin's Script Runner plugin, and I'm trying to set up a script that will fire an event if an issue is created with a priority of "Emergency". This event will then be picked up by the event listener, and I've got a notification scheme set up to send an email to a particular email address when the event gets fired.
Here's the script I'm using, based on (actually exactly) Jamie's example:
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.event.issue.IssueEventDispatcher
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import org.apache.log4j.Category
import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.event.issue.IssueEventSource
log = Category.getInstance("com.onresolve.jira.groovy.example.SendEmailOnBlocker")
if (issue.getPriorityObject().getName().equals("Blocker")) { // check if the priority is Blocker, change this line for other criteria
Issue updatedIssue = (Issue) transientVars.get("issue");
Comment comment = (Comment)transientVars.get("commentValue");
GenericValue changeGroup = (GenericValue) transientVars.get("changeGroup");
Map params = new HashMap(4);
params.put("eventsource", IssueEventSource.WORKFLOW);
IssueEventDispatcher.dispatchEvent(10000, updatedIssue, ManagerFactory.getWorkflowManager().getRemoteUser(transientVars), comment, null, changeGroup, params, true);
}
I'm supposed to update the "10000" above to the actual event ID, but that is the event ID for my event in this case, based on what I see when I hover over "edit."
The problem is, I never get the email. I know the workflow is set up correctly, as I put another post function on the same transition to send an email, using the built in functionality of the Script Runner plugin. The reason this doesn't work for me is that I don't know how to set up a new velocity template to format the email the way I want. Right now the email just says "test."
Any help anyone can provide would be great. Let me know what other info you need. Thanks.