Field codes set result issue

Hi,
It seems that the setResult() method for field codes has not been performing as it was expected to perform - it has been found not to change the field code value. We have found a workaround by going to the range element of the next sibling and replacing the value with the intended value, but it seems unwieldy. Could you please look into this issue? I have attached a sample documents and some sample code which doesn’t seem to affect the field code values.

Hi there,


Thanks for your inquiry. A field in a Word document is a complex structure consisting of multiple nodes that include field start, field code, field separator, field result and field end. Fields can be nested, contain rich content and span multiple paragraphs or sections in a document. The Field class is a “facade” object that provides properties and methods that allow to work with a field as a single object.

The content between the field start and separator is the field code. The content between the field separator and field end is the field result.

You can get and set the plain text version of the field result using the setResult and getResult methods. In your code, you are updating the field ‘field1.update()’ after setting its result. This update the field’s result according to the field code between the field start and separator. Hope this answers your query. Please let us know if you have any more queries.