displayResult property

Field.displayResult property

Gets the text that represents the displayed field result.

get displayResult(): string

Remarks

The Document.updateListLabels() method must be called to obtain correct value for the FieldListNum, FieldAutoNum, FieldAutoNumOut and FieldAutoNumLgl fields.

Examples

Shows how to get the real text that a field displays in the document.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

builder.write("This document was written by ");
let fieldAuthor = builder.insertField(aw.Fields.FieldType.FieldAuthor, true).asFieldAuthor();
fieldAuthor.authorName = "John Doe";

// We can use the DisplayResult property to verify what exact text
// a field would display in its place in the document.
expect(fieldAuthor.displayResult).toEqual('');

// Fields do not maintain accurate result values in real-time. 
// To make sure our fields display accurate results at any given time,
// such as right before a save operation, we need to update them manually.
fieldAuthor.update();

expect(fieldAuthor.displayResult).toEqual("John Doe");

doc.save(base.artifactsDir + "Field.displayResult.docx");

See Also