Footer with Nested If condition in word document not working when converted to aspose document using C# .Net

Hi

I am trying to merge the field in footer but the footer logic has manynested if condition in the word document so when I try to generate the document the mail merge does not work for this. The example for my nested if in the document is below.

{ IF { MERGEFIELD MD_BRAND } = "Jn" "21 Birchmount district, Suite 200, North Tower, Michigan, USA
L25 7J5
Telephone Toll Free 1.55.55.22.55
Email: account@gmail.com
" "{ IF { MERGEFIELD MD_BRAND } = "ME"
                 "
Address following 
                " "
(An image is inserted)
                " }"}`

I am using aspose 20.8.0 version.

Please let ,me know what I can do to make this mail merge work. Thanks

@Ajisha18 I have tested scenario in my side using the latest 22.8 version of Aspose.Words and the problem is not reproducible. IF field is updated properly. Here is a simple code used for testing:

Document doc = new Document(@"C:\Temp\in.docx");
doc.MailMerge.Execute(new string[] { "MD_BRAND" }, new string[] { "Jn" });
doc.Save(@"C:\Temp\out.docx");

Here is the template: in.docx (31.9 KB)

Also I have tested with RemoveContainingFields option and still the result is correct:

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;

Do you think this has something to do with the version.

@Ajisha18 Which version of Aspose.Words do you use? Could you please attach your template and output document here for testing? We will check the issue and provide you mor einformation.

I just upgraded to 22.8.0 with the trial version and still does not work my input doc is EXAMPLE_INPUT.docx (1.7 MB) The footer is not working other than that all the field are working

@Ajisha18 Thank you for additional information. But I cannot reproduce the problem on my side. I tested with different values and in all cases the field is evaluated properly. For example if use this code:

Document doc = new Document(@"C:\Temp\in.doc");
doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;
doc.MailMerge.Execute(new string[] { "MD_BRNDID" }, new string[] { "SC" });
doc.Save(@"C:\Temp\out.docx");

The output properly displays true value of of nested IF in false value of outer IF:

Thank you so much for your response.

1 Like