Jerome,
First of all, do you care if the attachment is a page level or document level attachment. Dynamic pdfs only allow document level attachments.
If you're expecting a page level attachment and you don't need any of the dynamic form features then you need to make sure your doc is saved as a static pdf. In which case the menu call should work.
To add a document level attachment to a dynamic pdf, you can't use the menu call -instead try something like this attached to the click event of a button:
var i = parseInt(attachCount.rawValue);
var oDoc = event.target;
oDoc.importDataObject("newattach" + i);
i++;
attachCount.rawValue = i;
}
else
{xfa.host.messageBox("Invalid attachment type!");
oDoc.removeDataObject("newattach" + i);
}
'commonScript' is a scriptObject (variable) listing the types of attachments you're willing to take. For example...
function hasValidExt(inPath)
{
var returnValue = false;
var uPath = String(inPath.toUpperCase());
if (uPath.indexOf(".DOC") > 0)
returnValue = true;
return returnValue;
}
The sample javascript is taken from a form that contains some other functionality associated with the attachments -so I needed a way to number/count the attachments in the subform. There is a hidden text field 'attachCount' that hold the doc count (var i). Of course there are other ways to do this.
If you're expecting to attach more than one file to the doc, then you'll still need to add the var i count in order to not rewrite the file every time you hit the attach button.
Hope this helps.