I’m seeing an odd issue where some mergefields within iffields are throwing an error on document.MailMerge.ExecuteWithRegions, I’ve attached an example. to give a bit of background on the example:
-MockMailMergeDataSourceNoChildren - is just a stand-in for any actual data I might use, as the issue seems to happen no matter what merge data we use
-MailMergePreparer - wraps mergefield with tableStart and tableEnd tags reflecting the main mergefield table - this is actual production logic we use, the merge data we get sent is wrapped in a root tag and we need to reflect that on the document for the mailmerges to correctly find the data for each field in the document
-The mailMerge settings in DoMailMerge reflect our settings from production code
as per the example, this only happens for the mergefield and if structure in the template.dotx file, and not for the templateModified.dotx. As manually going through every template we use and changing the if structure isn’t really possible, I wanted to check if there is something I can do programatically on my side to avoid running into this error? I’m expecting a tweak to the MailMergePreparer would be needed, but can’t really pinpoint where it causes the issue just by looking at the list of nodes and was hoping it would be easier on your side if you could debug into the library code. This seems to be happening on both aspose.words for .net 21.8 (our current production version) and on the latest.
mergefieldsExample.zip (38.6 KB)