Mail Merge Field in Nested IF Condition does not merge using .NET

Hi Aspose Team,

We are currently using Aspose Words 18.7 but due to a fix implemented in 19.7 (about foreign characters) we need to upgrade to at least 19.7 or ideally a more recent release such as 20.11.

When increasing the version number from 18.7 to 19.7 our current unit tests fail. Upon further investigation the exact version where it starts failing is 18.11. So version 18.7 - 18.10 is fine but version 18.11 - 20.11 doesn’t work as intended for us. The issue is that for some reason IF “” <> “” is accessing part of the true (only the word next to MERGEFIELD, not even the corresponding value) and skipping false when it should only access false.

The following picture shows the examples we’ve set-up. SD03A has been given a blank value and SD01X has been given the value 844. We’ve tried to cover a variety of examples that our clients use in their many templates, so really changing the syntax around isn’t an option for us.
asposeProblem.png (34.0 KB)

In version 18.7 - 18.10 it works as intended and gives us the following result:
image.png (8.3 KB)

But in version 18.11 - 20.11 we get the following output; Example 4 and Example 6 (same test but the only difference is speech marks around the MERGEFIELD value as we weren’t sure if this might be causing a potential issue) are incorrectly accessing the true from the IF instead of accessing the false AND it’s only printing out the text next to MERGEFIELD inside of the true, not the wrong thing which would be “Text Yes and 844. text”.
image.png (8.0 KB)

Please advise.

Thanks,
Lloyd

@LloydDavies

The MailMerge.UnconditionalMergeFieldsAndRegions property is used to get or set a Boolean value indicating whether merge fields and merge regions are merged regardless of the parent IF field’s condition. Please set the value of this property to true. Hope this helps you.

If you still face problem, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.