Insert Merge Field and Tables in IF Field & Execute Mail Merge on Word Document using Java Code

Hi,
I’m trying to do an IF block with mail merge, both in mustache and classic mode.
In classic mode I can’t put a control on a field, while in mustache mode I didn’t have any problems.
As indicated in “Perform Mail Merge on a Nested Merge Field inside Conditional IF Statement in Word Document using Java - #4 by awais.hafeez” I entered the code in the IF, but without result (always print MERGEFIELD).
It would be possible to download examples like those in the post “Insert Nested Merge Field inside IF Field in Word Document & Execute Mail Merge using Java” ?

Secondly I wanted to know if it is possible to insert more complex texts (e.g. tables, other fields etc …) in the part that will be written when the IF condition occurs.

Thanks so much

@marco.lui,

Please see TestDocs.zip (17.7 KB) and try running the following code:

Document doc = new Document("D:\\temp\\input.docx");
doc.getMailMerge().execute(new String[]{"show"}, new String[]{"true"});
doc.save("D:\\temp\\awjava-20.1.docx");

Please also check following document where I placed a Table inside True part of IF field. The same above code will show the Table while specifying false to merge field will hide it.

Perfect!
Thanks @awais.hafeez

A post was merged into an existing topic: If condition in merge fields