- Home
- Forum
- ASP.NET Web Forms
- IF Conditions in mailmerge template
IF Conditions in mailmerge template
Thank you for contacting Syncfusion support.
On further analysis of your requirement, we found that you are using Merge field in the If field expression. Currently DocIO doesn’t process the Merge fields within the fieldcode of If fields. We have prepared a sample for your requirement. Please find the sample from the following link and let us know if it helps.
Sample Link:
http://www.syncfusion.com/downloads/support/forum/121128/ze/Sample1562194760.zip
Please let us know if you have any other questions.
Regards,
Suganya
WField field = paragraph.AppendField("If", FieldType.FieldIf) as WField; field.FieldCode = "IF "; int fieldIndex = paragraph.Items.IndexOf(field); WMergeField mergeField = new WMergeField(document); mergeField.FieldCode = "MERGEFIELD Gender"; paragraph.Items.Insert(fieldIndex + 1, mergeField); WTextRange text = new WTextRange(document); text.Text = " = \"M\" \"Male\" \"Female\""; paragraph.Items.Insert(fieldIndex + 2, text); string[] fieldName = { "Gender" }; string[] fieldValue = { "F" }; document.MailMerge.Execute(fieldName, fieldValue); document.UpdateDocumentFields(); document.Save("Sample.docx", FormatType.Docx);
Thank you for your update.
Mail merge can be executed for Merge fields within the fieldcodes of IF fields using DocIO. We have modified the sample for your requirement. Please find the modified sample from the following link and let us know if it helps.
Sample Link:
http://www.syncfusion.com/downloads/support/forum/121128/ze/Sample-1936984544.zip
Please let us know if you have any other questions.
Regards,
Suganya
Thank you for your update.
We are not able to reproduce the mentioned field not updated issue using DocIO and we have prepared a sample to reproduce the issue at our side. Please find the sample we have tried at our end from the following link. Kindly modify the sample to reproduce the issue at our end.
Sample Link:
http://www.syncfusion.com/downloads/support/forum/121128/ze/Sample220860592.zip
If we misunderstood any of your requirement then kindly elaborate the actual requirement with detailed description and also your product version. Thereby we will analyze further on updating the document fields and will provided you appropriate solution.
Please let us know if you have any questions.
Regards,
Suganya
We are happy to hear that the issue has been resolved in 13.3.0.7 version. Please let us know if you need further assistance. We will be happy to assist you as always.
Regards,
Suganya
Thank you for your update.
We suspect that the reported IF field preservation issue might occurred due to the contents (elements) representation in your input template or code snippet with other data in different scenario based on the input data for Mail merge used at your end.
We need to analyze with your input Word document and Mail merge data to validate the mentioned problem at our end. So, kindly provide us the following details which will be helpful to analyze further on your requirement and update you the appropriate solution at the earliest.
1. Code snippet or simple runnable sample.
2. Input template.
3. Data set (dummy) used for Mail merge.
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same.
Please let us know if you have any other questions.
Regards,
Sethumanikkam.Y
Hi Suganya,
The aforementioned code snippet (https://www.syncfusion.com/forums/121128/if-conditions-in-mailmerge-template?reply=lEp3NS ) is not working with DocIO v20.2.
Can you please verify and send a sample compatible with the latest version.
Regards,
Hari
Hi Hari,
Essential DocIO library process the merge fields within the field code of If
fields.
From v16.1.0.24, we have migrated the field to the new structure. So, you have
faced the problem in that old sample code
example which has the old field structure.
Please refer the below link to know more about this migration,
https://help.syncfusion.com/file-formats/release-notes/migratingtov16.1.0.24
We have prepared the sample application in the latest version to process
the merge fields within the field code of If fields as per your requirement and
it can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-2029884514
Please refer our UG documentation link to know more about mail merge in the
Word document.
https://help.syncfusion.com/file-formats/docio/working-with-mail-merge
Regards,
Anto Nihil S
Hi Anto,
Thanks for your input. The sample works perfect.
Further to your sample, If I may ask - what can be done to include merge fields as a true or false statement in the IF field.
i.e. { IF 1=1 <<MergeField>> False } - I want to show the true expression as a merge field value.
Regards,
Hari
Hi Hari,
From the given details, we have found that your
requirement is to include merge fields as a true or false statement in the IF
field.
We have prepared the sample application to show the true expression as a merge
field value as per your requirement and it can be downloaded from the below attachment.
Regards,
Suriya Balamurugan.
Attachment: MergeField_In_True_Expression_ad6509a2.zip
- 13 Replies
- 8 Participants
-
CZ Christian Zeder
- Nov 12, 2015 04:51 PM UTC
- Oct 24, 2022 07:13 AM UTC