The following seems to have fixed: ... for (var i = 0; i <
attachments.length; i++) { var attach =
myDoc.openDataObject(attachments[i].name); try { if (attach != null) {
var field = oAttach.getField("myfield"); console.println("field:
"+field.value); xfa.event.cancelAction = true; if (attach.disclosed) {
attach.closeDoc(); } } } catch (error) { console.println(error); } } ...