In my workflow postfunctions I have
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?
I haven't come across that code before. At least that version of send custom email isn't in the latest versions of the product going back a few years.
Which version of ScriptRunner and Jira are you using?
Can you please post the fall stacktrace of the error you get? That should give us a line number it fails on.
The steps you've listed where you create the attachment and then send the email are all part of the same transition, correct?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.