IF formulas on Aspose.Word 7.0.0

{IF {MERGEFIELD ACT_number} <> "" {MERGEFIELD ACT_number} "empty"}

If i read the release notes of version 7.0.0 i would expect this should work now.

But it’s still not is that correct?

Hi

Thanks for your inquiry. I tested this on my side and all works fine. I used the following code for testing:

Document doc = new Document(@"Test001\in.doc");
doc.MailMerge.Execute(new string[]
{
    "ACT_number"
}, new object[]
{
    ""
});
doc.Save(@"Test001\out.doc");

My input and output documents are attached.
Best regards.

Ok, i see some diffrences allready…

my formula:
{IF {MERGEFIELD ACT_number} <> "" {MERGEFIELD ACT_number} "empty"}

your formula:
{IF "{MERGEFIELD ACT_number}" <> "" "{MERGEFIELD ACT_number}" "empty"}

I guess Word doesn’t put these extra quotes by default, is this necesary?

Ah… i discovered the issue… after i right mouse click on the field and choose update field it shows the correct value.

Can this be done by code?

Hi

Thank you for additional information. There is Document.Updatefields method, which updates all fields in the document. Please see the following ink for more information:
https://reference.aspose.com/words/net/aspose.words/document/updatefields/
I saw the difference between my field code and yours. However, I think, your field code is incorrect a bit. Let’s suppose that mergefield ACT_number has empty string as a value, In this case, your IF field code becomes incorrect, Like the following:
{IF <> "" "empty"}
But in my case it becomes correct and can be properly evaluated:
{IF "" <> "" "" "empty"}
Best regards.

OK, thanks for your reply, i’m gonna test it and let you know!

Yes it works great.
Thanks for the excellent support!