Expand my Community achievements bar.

Check if .xml file exists using javascript

Avatar

Level 1

I'm trying to determine if a specific .xml file exists on my desktop before running additional code. The following trusted script is in my Javascripts folder level. The "First Part" section below simply sets all fields of the form to be open. The second part looks for a .xml file in which to import XFA data from.

My problem is that I'm trying to determine whether this .xml file exists in the first place. Right now if it doesn't exist, it displays a dialog window requesting I browse for the file. Instead I'd like it to show an alert if the xml file does not exist, and never show the dialog at all. What code do I need to accomplish this? Thanks so much.

CODE:

var myTrustFunctTwo = app.trustedFunction(function(doc)

{

//First Part

  for (var nPageCount = 0; nPageCount < doc.numPages; nPageCount++) {

        var oFields = doc.xfa.layout.pageContent(nPageCount, "field");

  //app.alert(oFields,0);

        var nNodesLength = oFields.length;

        // Set the field property.

        for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {

            oFields.item(nNodeCount).access = "open";

        }

    }

//Second Part

app.beginPriv();
doc.importXFAData({

          cPath:"/c/Users/ME/Desktop/Filled_In.xml"

                          });

app.endPriv();
});

app.trustedFunction(myTrustFunctTwo);

0 Replies