We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Merge fields with no "False"

Hello,


I have found that when I have a series of nested IF’s within a Docx document, that unless those fields are written CORRECTLY - i.e A Condition, A True and A False element, the merge does not run properly, and fields can be missed.

For example:

{IF X=Y “TRUE” "
{IF A=B “”} <<< This has no false!
{IF C=D “” “”} << This won’t display the false, but the true as the quotes from the A=B are incorrect.
"}

Does Aspose end the Merge tag at the FieldChar.End? Or does it continue parsing? Also, is this a setting we can set? We have over 1000 (long & complex) documents, and can’t really change each document to make sure they’re correct.

Thanks
Hi Adam,

Thanks for your inquiry. To ensure a timely and accurate response, it would be great if you please create a standalone runnable simple console application that helps us reproduce your problem on our end and attach it here for testing. As soon as you get this simple application ready, we'll start investigation into your issue and provide you more information. Also, please attach the template Word document and output document showing the undesired behavior here for testing. Thanks for your cooperation.

Best regards,

Hi Awais,


Thanks for your response, please find an attached VS Solution, with sample code, and 2 sample documents.

One is the template, which is a letter (despite being highly reduced), which we merge and send to our customers. I have reduced this down to a specific area, to make the issue easier to show.

As you can see, the document should, depending on the value of certain fields - show/not show some text.

The “OCC” merge field is set to Y, which, as a result should show the main content, but due to the lack of quotes on following merge fields, it is causing this field to evaluated incorrectly.

Should you need any more information, please don’t hesitate to ask.

Thanks,

(Attached)

Hi Adam,


Thanks for the additional information. We are checking with this scenario and will get back to you soon.

Best regards,

Hello,


Do you have an update for this? It’s quite important for us, and could be regarded as a broken feature of Aspose.Words!

Thanks,

Hi Adam,


Thank you for being patient. Please spare us some time for the analysis/investigation. We will get back to you as soon as possible.

Best regards,

Hi Adam,


Thanks for being patient. I have attached a simplified template Word document “input.docx” here for your reference. Please try producing output documents from it by executing the following cases.

case 1: This should display text [ IF1_TRUE ] as X=Y is true.

doc.MailMerge.Execute(new
string[] { “X”,
“Y”, “A”,
“B”, “C”,
“D” },

new
string[] { “1”,
“1”, “2”,
“2”, “3”,
“3” });


case 2: This should display text [ IF2_TRUE and IF3_TRUE ] as X=Y is false

doc.MailMerge.Execute(new string[] { “X”, “Y”, “A”, “B”, “C”, “D” },

new string[] { “1”, -1, “2”, “2”, “3”, “3” });


case 3: This should display text [ IF3_TRUE ] as X=Y and A=B are both false

doc.MailMerge.Execute(new string[] { “X”, “Y”, “A”, “B”, “C”, “D” },

new string[] { “1”, -1, “2”, -2, “3”, “3” });


case 4: This should display text [ IF3_FALSE ] as X=Y, A=B and C=D are all false

doc.MailMerge.Execute(new string[] { “X”, “Y”, “A”, “B”, “C”, “D” },

new string[] { “1”, -1, “2”, -2, “3”, -3 });


In this case Aspose.Words’ behavior is correct. Please let us know if we can be of any further assistance.

Best regards,