Merge Ranges not working if more than one fields are present in the document

Hi

The merge range fields are not working fine if two range fields are there in the document with the same name.

Hi Nitin,

I was unable to reproduce this issue, here is the document I tried:

merge-ranges

And here is the snippet code I used:

var document = DocumentModel.Load("input.docx");

var source = new
{
    Names = new[]
    {
        new { Name = "John" },
        new { Name = "Jane" },
    }
};

document.MailMerge.Execute(source);

document.Save("output.docx");

The resulting document has both “John” and “Jane” paragraphs repeated twice, once for each “Names” range.

Regards,
Mario

Hi Mario

Thank you!

The problem was occurring after running MailMerge.Execute() method on the data table.

The problem is resolved after converting the datatable to the dictionary as per the mentioned source format you shared.

Hi Nitin,

My example is using an array of anonymous objects, which is similar to a DataTable source (in a way that they both have multiple records).

Anyway, can you show us what kind of merged ranges you have in your document?

Regards,
Mario