MailMerge with both Execute and ExecuteGroup does not work

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);

However if I just keep only one of lines it works, but the issue is it only fills in the data for the fields corresponding to that line. Am I missing something here? How do I make the both the Execute statements work?

Thank you. 




4 Replies

LB Lokesh Baskar Syncfusion Team June 22, 2021 08:37 PM UTC

Hi Cloud,

Thank you for contacting Syncfusion support.

We have tried to perform mail merge using ExecuteGroup and Execute but it is working fine at our end.
For your reference we have attached the sample application at our end.Please refer the sample from the below link:
 
https://www.syncfusion.com/downloads/support/forum/166555/ze/DocIOSample1415179937.zip

We suspect that the reported problem might be due to the file level information in the input Word document which used at your end. So, to analyze further on the reported problem, could you please provide us the following things from your end:
 

 1. Input Word document.
 
 2. Code snippets or modified sample of above to reproduce the problem. 
 3. Syncfusion product version used at your end. 

This will be more helpful to check and share the details at the earliest.
 

Please let us know if you have any other questions.


Regards,
Lokesh B 



PS Pieter Swart August 19, 2022 02:04 PM UTC

I'm having the same problem.

I took your example and upgraded to the latest version of the nuget packages so version 

Snippet
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


Attachment: ConsoleSample_24bc5230.zip


AN Anto Nihil Sahaya Raj Syncfusion Team August 22, 2022 04:17 PM UTC

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



AN Anto Nihil Sahaya Raj Syncfusion Team August 24, 2022 04:41 PM UTC

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


Attachment: ConsoleSample_a6c2f53b.zip

Loader.
Up arrow icon