Skip to main content
Participant
July 18, 2014
Answered

.FirstXRefInDoc not working

  • July 18, 2014
  • 1 reply
  • 488 views

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?

This topic has been closed for replies.
Correct answer twoclicks-jh5Ppz

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

1 reply

frameexpert
Community Expert
Community Expert
July 18, 2014

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

www.frameexpert.com
twoclicks-jh5PpzAuthorCorrect answer
Participant
July 19, 2014

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

Legend
July 21, 2014

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