Skip to main content
Kasyan Servetsky
Legend
March 18, 2017
Question

Problem with updating cross-references

  • March 18, 2017
  • 1 reply
  • 597 views

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.

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.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

This topic has been closed for replies.

1 reply

Vamitul
Legend
March 19, 2017

are the book documents (indd's) opened when you call update?

Kasyan Servetsky
Legend
March 19, 2017

Yes, the script opens all the documents in the active book at start.

— Kas