0 Replies Latest reply on May 29, 2018 12:32 AM by Pontus Hulin

    Indesign shuts down when closing a document

    Pontus Hulin Level 1

      Hello

      We have a plugin that closes a document after the customer preforms a certain action. If there is only one document open, InDesign shuts down after the document is closed, if the user activates an other program. It happens when InDesign loses focus after the document is closed. This only happens when only one document is open. If there are multiple documents open, there is no problem.

      We are using InDesign CC2015 on Mac OS X.

       

      Here is the function that makes InDesign shut down, if I uncomment the alert("document was closed") line, InDesign does not shut down, so I suspect this is some kind of viewport problem. Is there any way around this?

       

      function cargo_closeDocumentByID(object) {

         

          var string = unescape(object);

          var exportObject = JSON.parse(string);

          var result = {

              error:""

          };

         

          var result = {

              error:"",

              fileList:[]

          };

        

          try {

              if (app.documents.length > 0) {

                  for(var i=0; i < app.documents.length; i ++) {

       

                      var doc = app.documents.item(i);

                      var jobID = getCargoJobIDFromDocIn(doc);

                      if (exportObject.jobID == jobID) {

                          doc.close(SaveOptions.YES);

                          break;

                      }

                  }

              }

          } catch(error) {

              result = error.message;

              alert(error.message);

          }

          // alert("document was closed");

          return JSON.stringify(result);

      }