Reading merge fields broken after update

While reading mail merge field using Aspose Words I got incorrect result for fields like {MAILMERGE Country Name}, it is only reading it as Country and not as Country Name.
An older version of Aspose was actually reading the field as Country Name. The newer version reads that field as Country Name only when we do {MAILMERGE "Country Name" }.
Can anyone point out on standard practice on creating the mail merge field and if we have any library in Aspose which would read the tag correctly even without quotation marks.
I am using wordDocument.MailMerge.GetFieldNames() to read those fields.

Hi Suraj,

Thanks for your inquiry. Could you please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.

Moreover, I suggest you please read following documentaion links for your knid reference.
https://docs.aspose.com/words/net/mail-merge-template/
https://docs.aspose.com/words/java/mail-merge-and-reporting/

The first merge field used to be read as First Name before, now it is read only as First

The second merge field is however read as Last Name

Hi Suraj,

Thanks for sharing the document. Please note that Aspose.Words tries to mimic the same behavior as MS Word do. Please update the mail merge fields via MS Word, the First Name field will be converted to <<First>> only.

Moreover, please try to insert mail merge field like First Name via MS Word (space between mail merge filed name), MS Word adds double quotes around it (“First Name”).

Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,

Thank you for your reply. We have been using your product since last five years and we are getting this behavior only after I updated with newest Aspose, so if you could point me to documentation so as to which version it started to change it, it will be easier for me to explain to our clients and update my code base accordingly. We updated from version 6 to version 11.

Thanks again.

Furthermore if you could suggest me other way to make it work like before with new version of Aspose, that will be great too.

Hi Suraj,
Please accept my apologies for late response. You were using quite old version of Aspose.Words and the latest version of Aspose.Words contains many new features, enhancements in the existing features and bug fixes.
Please note that Aspose.Words tries to mimic the same behavior as MS Word do. You can use the following code snippet to achive you requirements. Hope this helps you.

Document doc = new Document(MyDir + "asposetestdocument.doc");
DocumentBuilder builder = new DocumentBuilder(doc);

ArrayList fields = new ArrayList();

foreach (FieldStart fStart in doc.GetChildNodes(NodeType.FieldStart, true))
{
    string fCode = fStart.GetField().GetFieldCode();
    if (fCode.Contains(@"""") != true)
        fields.Add(fStart.GetField());
}

foreach (Field fld in fields)
{
    builder.MoveToField(fld, true);
    builder.InsertField(@"MERGEFIELD """ + fld.GetFieldCode().Replace("MERGEFIELD", "").Trim() + @"""");
    fld.Remove();
}

doc.Save(MyDir + "out.docx");