Hello, I have document with some MailMerge fields, and one MailMerge Table. The code opens the document, retrieves the data for the fields, then does the below, this does NOT work.
document.MailMerge.ExecuteGroup(dataTable);
document.MailMerge.Execute(fieldNames, fieldValues);
I'm having the same problem.
I took your example and upgraded to the latest version of the nuget packages so version
20.2.0.44
I also used the GetDataTable() method as the data source for the ExecuteGroup so it has different data in the table.
In the example you provide you created 3 rows of sample data.
so if you do this, you will see it does not work
Hi Cloud
admin,
We have reproduced the reported issue “Group merge fields are not executed properly while executing
mail merge using both Execute() and ExecuteGroup() methods” in our end,
and we suspect it to be a defect. We will validate this issue and update you
with more details on 24th August 2022.
Regards,
Anto Nihil S
Hi Cloud admin,
On further validating the reported issue, we found
that the merge field inside the group and outer are in same name. So while
executing merge field (wordDocument.MailMerge.Execute(fieldNames, fieldValues)),
the field inside group also execute. This is the behavior of Microsoft Word
too. So that reported issue occurs.
As a workaround, we suggest you
following ways to resolve that reported
issue at your end.
1.Execute group merge field first (wordDocument.MailMerge.ExecuteGroup(GetDataTable())).
Because while executing the group merge field, it execute only field inside the
group merge field. So it will not affect the individual merge field. So now
execute the individual merge field provide valid result. Please find the
modified sample below attachment.
(or)
2. Set different names
for merge field inside group and outer in template Word document.
Please let us know if you need any further assistance in this.
Regards,
Anto Nihil S