I tried the code below in FrameMaker 10 and it gives me the first cross-reference in my document. However, the UpdateXRefs() method does not appear to work.
#target "framemaker-10.0" var doc = app.ActiveDoc; var xref = doc.FirstXRefInDoc; alert (xref); doc.UpdateXRefs (Constants.FF_XRUI_FORCE_UPDATE);
Indeed, you are right, doc.FirstXRefInDoc really returns Xref object, I was misled by line number that returned the undefined error, also thanks to this I was able to eliminate the real source of this particular error: I tried to get the next Xref by calling doc.NextXrefInDoc, but while FirstXrefinDoc is a property of Doc, NextXrefInDoc is a property of particular Xref, hence the undefined error. In your code, xref.NextXrefInDoc would return next cross-reference. Now I am able to traverse through all cross-references in doc.
However, the core of the problem persists - neither doc.UpdateXRefs, nor xref.UpdateXRef seems to be doing anything, Although the cross-references do not manifest themselves in Framemaker as unresolved (they point to a correct document and are "green" in cross-reference panel) calling update does not refresh their text (e.g.: page 14) - it is empty and only gets populated when I manualy select Edit - Update References.
When saved as mif file, these strange cross-references do not have <XRefLastUpdate> property (not even after calling doc.UpdateXRefs). This property is only generated after the mentioned manual process. So what really need is something that triggers the same process that populates those xrefs. Maybe it is not UpdateXRef, however I can not find anything analogous in documentation.
Thanks for your help so far
I tried the UpdateXRefs() call with Constants.FF_XRUI_FORCE_UPDATE and got the same results. But, it seems to work with FF_XRUI_EVERYTHING. Try that.
That's the constant I've used in my FDK plugins with success.
works in my situation, but I have found out why and will record it here for future generations
Updating of references does not work, when the document is opened from mif file and unsaved as fm. (I somehow thought that opened documents are equal, regardes of their representation on hard drive, clearly there are some exceptions.)
So my above problem is then actualy solved without any need co call UpdateXRefs, now my script saves the opened doc as temporary fm file, closes the mif, opens the temporary fm file (here those strange semi-working references get updated to normal xrefs) and then saves this file as original mif (as I need the mif for further processing outside fm).
Thank you both guys for your suggestions, they nudged me out of circular thinking and helped me to find this out.