In my workflow postfunctions I have
- Set issue status to the linked status of the destination workflow step.
- Add a comment to an issue if one is entered during a transition.
- File Request.pdf will be created from template Account Access.docx in the pdf format and it will be attached to issue with name .
- File Request.docx will be created from template Account Access.docx in the docx format and it will be attached to issue with name .
- Update change history for an issue and store the issue in the database.
- Re-index an issue to keep indexes in sync with the database.
- Fire a Generic Event event that can be processed by the listeners.
- ScriptRunner workflow function - Send a custom email
Send Request to Assigned Manager
postfunction 3 is an xporter plugin that creates the attachment "Request.pdf"
postfunction 8 is a canned "Send a custom email" scriptrunner script for sending emails. This script has the following custom attachment callback.
import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.MailAttachment
{MailAttachment a ->
a.isNew() && a.filename.toLowerCase().endsWith('.pdf')
}
When I perform the transition I receive the email but without any attachments
In the log I see the following entry
[c.o.s.c.j.workflow.postfunctions.SendCustomEmail] Failed to evaluate closure for adding attachment to email
java.lang.NullPointerException: Cannot get property 'id' on null object
at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:172)
at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
I found some code on pastebin for the canned script
class SendCustomEmailUniqueAttachment implements CannedScript{
.....
.....
private def addAttachmentsToMail(Map<String,String> params, MutableIssue issue, Email email) {
.....
.....
if (params[FIELD_INCLUDE_ATTACHMENTS] == FIELD_INCLUDE_ATTACHMENTS_CUSTOM) {
def gse = CannedScriptRunner.getGse()
try {
def callback = gse.eval(params[FIELD_INCLUDE_ATTACHMENTS_CALLBACK])
// todo: isNew method - see previous versions for ideas
def mailAttachment = new MailAttachment(attachment)
mailAttachment.setIsNew(newAttachmentIds.contains(attachment.id))
def result = callback.call(mailAttachment)
// Attachment.metaClass.
log.debug "callback result for ${attachment.filename}: " + (result as Boolean)
if (! result) {
return
}
} catch (e) {
log.error("Failed to evaluate closure for adding attachment to email", e)
return
}
}I assume is dying on the "mailAttachment.setIsNew(newAttachmentIds.contains(attachment.id))" line
Any ideas on how to work around this problem?