Free Support Forum -

Conditional mergefields with more than one mergefield


I would like to use conditional mergefield (IF condition) with more than one field used in the expression, something like this:<span style=“font-size: 11pt; font-family: “Calibri”,“sans-serif”; color: rgb(31, 73, 125);”><span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;


This seems to work when we do the merge, but unfortunately these fields don’t seem to have a external label or text and enhance they seem to be hidden or not visible in the word doc file.

<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
color:#1F497D”>It would be great help if you could point me to some references
for conditional mail merge with nested merge field references.



Thanks for your request. I checked this on my side and IF field is properly updated. I used the latest version of Aspose.Words, the attached template and the following code for testing:

Document doc = new Document("C:\\Temp\\in.doc");

doc.getMailMerge().execute(new String[] { "ENTRY_SHOWTOTAL", "ENTRY_TOTAL" }, new Object[] { "T", "123456789" });"C:\\Temp\\out.doc");

Probably this does not work on your side because you are using old version of Aspose.Words for Java. The versions older than 10.0.0 do not support updating fields. So please try using the latest version, you can download it from here:

Best regards,

Hi alexey,

I use the latest version 10.1, the merge itself works.

My question was to do with the word doc file which contains the IF conditional merge field, unless we show merge field code this field doesn’t seem to be visible…


Thank you for additional information. Unfortunately, it is still not quite clear for me what you mean. Do you mean that the IF field is invisible in your source document before merging? If so the explanation is quite simple. Here is field code of your IF field:


The condition is highlighted with yellow, if this condition is true, then you will see the value highlighted with green if false with red. Since before merging the condition is False, you see the empty string (red value).

Best regards,


I am attaching one image file outlining the field which i am not able to see in word and also attaching the doc sample file for reference…

Hi Ravikumar,

Thanks for your request. This is an expected behavior. Condition in your IF field does not pass and that is why you see the value that should be displayed when condition is false. In your case this value is an empty string.

Best regards,