Hi Aspose,
We can see a change in behaviour in the latest version of Aspose Words when performing a mailmerge that does not seem right. When an INCLUDETEXT field is used to include another document that sets a value to be used in the original document, the value is not included in the result. This was working as expected in Aspose 20.11 and earlier but has changed in Aspose 20.12 onwards.
Attached is a minimal test case. To run, replace the licence file and run with IntelliJ.
The expected result is that the output document mailmerge-result.docx should contain the text “Manager The RED pension scheme Ltd Redhill” because that is the value of the REF SigBlock defined by the included document. A copy of the expected result (generated with the same code and Aspose Words 20.11) and the actual result with Aspose 21.1 are included in the example.
Included in the code are some commented-out lines that represent things we currently do in our real application to give some context, specifically we use the option setUnconditionalMergeFieldsAndRegions and we also update IF fields before unlinking them. However neither of these changes makes a difference in this case.
I can’t see a clear workaround for this issue. If I update all fields before unlinking, then the text is included, but it is duplicated which is incorrect. If I change the data source so that there are no records (i.e. change MyDataSource so that moveNext always returns false) then the result is as expected, but this is not possible in a real application because the data source will always contain records.
Please can you advise if this is a bug that should be fixed, or if there is some other way we can get our examples like this to work as expected?
Many thanks in advance,
Ned Smith
aspose-includetext-testcase.zip (118.4 KB)