Hello,
I am trying to create some cross-references to some paragraphs.
With what I wrote so far, a cross-reference appears to be added to the text Frame, but not text is shown and the Source Type is selected as "Cross-Reference Markers". Here I would like to have "Paragraphs".
Also, the cross-reference doesn't seem to be formated with the format I specify (it is not blue).

This is what I wrote so far:
// I wrote this function to get the UID from a table I have.
function getUID(paragraphFormat, text) {
table = doc.FirstTblInDoc;
try {
row = table.FirstRowInTbl;
}
catch (e) {
$.writeln("There was an error. No table found: " + e);
}
rowNr = 1;
while (rowNr < table.TblNumRows) {
cell = row.FirstCellInRow;
paragraph = cell.FirstPgf;
if (paragraph.Name == paragraphFormat && paragraph.PgfNumber == text) {
paragraphFound = true;
return paragraph.Unique;
}
row = row.NextRowInTbl;
rowNr++;
}
}
var graphic = null;
var doc = app.ActiveDoc;
graphic = doc.FirstSelectedGraphicInDoc;
var frameParent = graphic.FrameParent;
var textFrameObj = doc.NewTextFrame(frameParent);
textFrameObj.LocX = 20 * MM;
textFrameObj.LocY = 50 * MM;
var paragraph = textFrameObj.FirstPgf;
startLoc = new TextLoc(paragraph, 0);
endLoc = new TextLoc(paragraph, Constants.FV_OBJ_END_OFFSET);
crossreference = doc.NewAnchoredFormattedXRef("Paragraphs", startLoc);
crossreference.XRefSrcIsElem = false;
textRange = new TextRange(
startLoc,
endLoc
);
crossreference.TextRange = textRange;
xRefSrcText = getUID("Body", "10") + ":Body:10";
crossreference.XRefSrcText = xRefSrcText;
doc.UpdateXRefs(doc, crossreference);