Copy link to clipboard
Copied
Hello,
I try to parse xrefs in a doc (and update them), but I have trouble getting the reference to fist xref.
var comp = doc.FirstXRefInDoc;
returns undefined, although there are xrefs in a file. I work in FM 10.
also global update doc.UpdateXRefs does not seem to have any effect.
When I do manualy Edit - Update references, xrefs in document get updated. Are these properties and methods tied to FM11, in that case, what options I have in FM10?
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 throug
...Copy link to clipboard
Copied
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);
Rick
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi,
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.
doc.UpdateXRefs (Constants.FF_XRUI_EVERYTHING);
That's the constant I've used in my FDK plugins with success.
Russ
Copy link to clipboard
Copied
Neither
doc.UpdateXRefs (Constants.FF_XRUI_EVERYTHING);
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.