I have a database connected XFA form that opens and fills out a separate 'report' form before sending it to the client via email. The issue i'm having is trying to transfer over all PDF attachments to the report form so that they get sent along with the report form.
var doc = event.target;
var reportDoc = null;
var attachment = null;
var formData = dataBridge.getData();
//Open the report file
reportDoc = app.openDoc({
cPath: "Design Request Report.pdf",
oDoc: doc,
bHidden: true
});
//Attach documents
if (doc.dataObjects) {
doc.dataObjects.forEach(function(obj, i, a) {
//Only pdf files will be supported
if (obj.MIMEType == "application/pdf") {
try {
attachment = doc.openDataObject(obj.name);
reportDoc.embedDocAsDataObject(obj.name, attachment);
attachment.closeDoc(true);
}
catch(err) {
if(attachment)
attachment.closeDoc(true);
errorUtil.throwError(err);
}
}
else {
xfa.host.messageBox("Warning: Only pdf attachments are currently supported.\n" + obj.name + " is about to be removed.");
}
doc.removeDataObject(obj.name);
});
}
However regardless of the pdf attachment I use, I always get the following error when it tries to embed the attachment in the report:
InvalidArgsError: Invalid arguments.
Doc.embedDocAsDataObject:35:XFA:topmostSubform[0]:Page1[0]:button[0]:click
===> Expected 585365752 parameters.
Why won't Doc objects obtained from DataObjects embed themselves into another report?
Note that embedding event.target works as intended, but not an embedded version of the same file.