3 Replies Latest reply on Jan 12, 2016 2:41 AM by Unique

    execDialog function externally from Folder level script

    Unique Level 1

      HI Forum..


      Happy New New.


      I Need a support from you. I'm using the Folder Level script which is loaded in Acrobat/Javascript folder and while running the script I wanted to call the app.exec Dialog functions code saved at external servers. I have tried this by importDataObject method to load the execDialog script into PDF as an attachment and then reading the codes using getObjectData method.


      // Loaded the below script in Acrobat/javascript folder....



      var rajniTrust = app.trustedFunction(function()





      var oFile = util.readFileIntoStream("/Users/rnarayanan/Desktop/ABERDEEN_Checklist.js");

          //var c = util.stringFromStream(oFile);

      this.importDataObject("oFile", "/Users/rnarayanan/Desktop/ABERDEEN_Checklist.js");


      var oFile = this.getDataObjectContents("oFile");

      var cFile = util.stringFromStream(oFile, "utf-8");


      AFExecuteThisScript(cFile); // THIS IS NOT EXECUTING THE Script.......







      var DoCmdImportNamedAttach =

      "// Enter your JavaScript code here\n" +

      "// Or select one or more JavaScrippets\n" +







      //<JSCodeSnippet name="ButtonObjDef">

      var oButObjImportNamedAttach =

      {cName: "ImportNamedAttach",

      cExec: DoCmdImportNamedAttach,

      cEnable: "event.rc = (app.doc != null)",

      cMarked: "event.rc = false",

      cTooltext: "Rajni_Automation",

      nPos: -1};


      if(oIconImportNamedAttach != null)

      oButObjImportNamedAttach.oIcon = oIconImportNamedAttach;


      //<JSCodeSnippet name="TryAddBut">




      //<JSCodeSnippet name="AddButtonfn">



      if((event.type == "Doc") && (app.viewerVersion >= 7))

      global["ImportNamedAttach_InDoc"] = "3:28:2009:9:48:55";


      global["ImportNamedAttach"] = "3:28:2009:9:48:55";

      //<JSCodeSnippet name="CatchAddBut">



      if((global.bReportNameCollision != null) && (global.bReportNameCollision == true))


      var strError = 'Cannot Install AcroButton "oButObjImportNamedAttach"\n';

      strError += ':' + e.fileName + '\n';

      strError += 'Error: ' + e.name + '\n';

      strError += e.message + '\n';

      strError += 'Possible Name conflict';

      app.alert(strError,0,0,'AcroButton Error');






      Thanks for the help.

        • 1. Re: execDialog function externally from Folder level script
          try67 MVP & Adobe Community Professional

          I don't see anywhere where the AFExecuteThisScript function is defined... I also don't see it in the internal functions of the application.

          What did this come from and why do you think it should work?


          To run raw code you can use the eval command of JS.

          • 2. Re: execDialog function externally from Folder level script
            Bernd Alheit Adobe Community Professional & MVP

            You can use the function AFExecuteThisScript in a plug-in. It is not a Javascript function.

            • 3. Re: execDialog function externally from Folder level script
              Unique Level 1

              hi try and Bernd.... Thanks for the update. It works now.


              Please advice/support on the further need using the same eval command.

              Script functions :


              1) loaded folder-level-script to create toolBar button and while clicking the toolBar button it will trigger eval command to run "abcd.js" file located somewhere in the server (solution as suggested by "try69" - command "eval" to run js file)


              2) Now I have added "additional function "importDataObject and getDataObject" in that abcd.js file" (unfortunately, I can't able to excute the second js file even the same eval command is used.


              3) Also I can't able to verify or get alert of the variable "var doc =this.documentFileName;  from the externally called abcd.js file. (error: doc is undefined).


              please advice on the above 2 request.


              Thanks very much for the support.