Free Support Forum - aspose.com

MailMerge.GetFieldNames() in fields

Hi

My code relies on the ability to resolve what mergefields exists on a form. If I create a field like this:

{ IF "{ MERGEFIELD field1 }" = "" "{ MERGEFIELD field2 }" "{ MERGEFIELD
field3 }" }

And then perform this code on it:

string [] mergeFields = doc.MailMerge.GetFieldNames();

Will the string array contain the mergefields?
field1
field2
field3

Logically it should as it is mergefields on the template. But I haven't been able to make it work. These mergefields do not appear anywhere else on the template, only in the IF field.

Regards,

!Rob

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words for .NET 10.5.0. You can download this version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Please see the attached document.

It seems the IF field inside your document does not contain any MergFields just a simple text. To insert one field into another field you should press Ctrl-F9.

Best regards,