Problem with updating cross-references
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