If statement in mail merge not working as per requirement

I have 

this as merge filed condition and I am passing the datatable with associate mergefield tags but in the output file we are getting the 


instead of this condition there should be only "Shaishav" should be displayed on the output document


1 Reply

AN Anto Nihil Sahaya Raj Syncfusion Team July 3, 2023 01:57 PM UTC

Hi Shaishav,

From the given details, we have found that the IF field results are not updated properly in the output document. To achieve your requirement, we recommend you to call the UpdateDocumentFields API after executing mail merge to get the proper results for all fields in the Word document. Because while calling UpdateDocumentFields API, it updates the field result based on merged field execution. So we can get proper results for all fields in the Word document.

We have prepared a sample application to achieve your requirement. It can be downloaded from the attachment.

In this attached sample, we have done the following things.
1. Opens the input Word document.
2. Create a data table and executes the mail merge based on that data table.
3. Update the fields in the Word document using
UpdateDocumentFields API.
4. Saves the Word document.


Please refer our UG documentation to know about UpdateDocumentFields API,
https://help.syncfusion.com/file-formats/docio/working-with-fields#updating-fields


Regards,
Anto Nihil S


Attachment: Mailmerge_e8e4abfc.zip

Loader.
Up arrow icon