Expand my Community achievements bar.

SOLVED

not getting data from attachments

Avatar

Level 1

I have the below code in Desiger 10 and it works for the first one or two attachments but then will error out with the following error:

Unhandled exception at 0x5CFCF19A (EScript.api) in Acrobat.exe: 0xC0000005: Access violation reading location 0x80000000.

Code:

var myDoc = event.target;

var attachments = myDoc.dataObjects;

if (attachments == null) {

    app.alert("No attachments found!");

} else {

    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);

               attach.closeDoc();               

            }

        } catch (error) {

            console.println(error);

        }

    }

}

console.println("Done loading attachments");

Once this works, there is more code to add.

Help!

1 Accepted Solution

Avatar

Correct answer by
Level 1

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);

        }

  }

          ...

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

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);

        }

  }

          ...