2 Replies Latest reply on Mar 19, 2017 3:18 AM by Kasyan Servetsky

    Problem with updating cross-references

    Kasyan Servetsky Level 5

      Hi everyone,

       

      Today I wrote a script which creates cross-references across all documents in all open documents. (I use a simple book of three documents for testing)

      When the script is complete, I end up with a number of ‘outdated’ cross-references.

      18-03-2017 18-51-44.png

      For that reason, at the end, I added a function which updates all cross-references in all open documents:

      UpdateXrefs();
      
      function UpdateXrefs() {
          for (var i = 0; i < app.documents.length; i++) {
              app.documents[i].updateCrossReferences();
          }
      }
      

      But , for some reason, this doesn’t work: they still remain outdated. I tried all variations that came to my mind -- looping cross-references one-by-one forwards/backwards, using .everyItem(), tried to set the script on pause ($.sleep(10000)) before calling the update function, etc. -- but nothing works.

      However, when I run the same function as a separate script, it works as expected.

      Any ideas why it doesn’t work as part of the ‘main’ script?

       

      Regards,
      Kasyan