UpdateXRefs does not update
Dear friends,
My whole script now works fine with the exception of the XRef update after inserting a new XRef. It works correctly if the target of the XRef is in the same file as the XRef (oDoc == oTgtDoc). Both files are open at the time of the update - and the active document is that with the XRef (oDoc).
→ What may be the problem here?

The blue XRefs all work correctly and point to a separate file (\endnotes). Manual updating with the GUI is OK, but why does this not work in the script?
// --- Build new XRef and insert it at saved location
Fno_SelectParagraph (oDoc, oPgfNew); // Required
oTgtTL = new TextLoc (oPgfNew, 0);
Fno_RestoreLocation (oDoc, oUserLoc);
oTL = oUserLoc.txtRange.beg;
oXRef = Fno_InsertXRef (oDoc, oTL, sXRefFmt, oTgtDoc, oTgtTL);
oDoc.UpdateXRefs(Constants.FF_XRUI_EVERYTHING); // note done in book files !!!!!!!!!!
alert ("UpdateXRefs error: " + FA_errno);
// --- Jump to the empty Endnote -----------------------
Fno_FollowXRef (oDoc, oXRef);
oENloc = Fno_SaveCurrentLocation (oTgtDoc);
Fno_RestoreLocation (oTgtDoc, oENloc);
oUserLoc = oENloc.txtRange.end;
oUserLoc.offset += 1; // go behind the marker.
oTgtDoc.TextSelection = new TextRange (oUserLoc, oUserLoc);
} //--- end Fno_InsertEndnote
// --- Build new XRef and insert it at saved location
Fno_SelectParagraph (oDoc, oPgfNew); // Required
oTgtTL = new TextLoc (oPgfNew, 0);
Fno_RestoreLocation (oDoc, oUserLoc);
oTL = oUserLoc.txtRange.beg;
oXRef = Fno_InsertXRef (oDoc, oTL, sXRefFmt, oTgtDoc, oTgtTL);
oDoc.UpdateXRefs(Constants.FF_XRUI_EVERYTHING); // note done in book files !!!!!!!!!!
alert ("UpdateXRefs error: " + FA_errno);
// --- Jump to the empty Endnote -----------------------
Fno_FollowXRef (oDoc, oXRef);
oENloc = Fno_SaveCurrentLocation (oTgtDoc);
Fno_RestoreLocation (oTgtDoc, oENloc);
oUserLoc = oENloc.txtRange.end;
oUserLoc.offset += 1; // go behind the marker.
oTgtDoc.TextSelection = new TextRange (oUserLoc, oUserLoc);
} //--- end Fno_InsertEndnote

