6 Replies Latest reply on Mar 8, 2016 5:24 PM by jeremy0013

    File Exists using folder level

    jeremy0013 Level 1

      Need some help here.  I am writing some javascript on a acrobat form using a folder level script to see if a file exists.  This does not seem to work for me for some reason.  If don't have LiveCycle will the code below still work?  Is there a setting I am missing?

       

      Folder Level

      var IfFileExists = app.trustedFunction(function(filename) {

          app.beginPriv(); 

          var existingDoc = false; 

          try { 

               var checkDoc = app.openDoc(filename); 

               checkDoc.closeDoc(); 

           existingDoc = true; 

          } catch(e) { 

           existingDoc = false; 

          } 

          return existingDoc; 

          app.endPriv(); 

      }); 

       

      Doc Level

      var onumber = this.getField("info_Order#");

      var FileDir = ("/Volumes/PFS/" + onumber.value + ".fdf");

       

      if(typeof(IfFileExists) == "function") { 

          try { 

              if(IfFileExists(FileDir) == true) { 

                  app.alert("file is there"); 

              } else { 

                  app.alert("file is NOT there"); 

              } 

          } 

          catch(e) { 

              app.alert("file is NOT there");   

          }