Nested regions are broken when no child rows

Hi all,
I work with nested mailmerge regions, with attached template (DOCX) I get provided results (PDF).
Problem is that if there are no child rows related to specific parent row, Aspose substitutes all rows from child table to that parent row.
You may check out screenshots of dataset which is used for attached PDF.
Here is the code (reduced)

var data = new DataSet("Data");
var activity_table = data.Tables.Add("Activities");
activity_table.Columns.Add("Activity", typeof(string));
activity_table.Columns.Add("InvoiceId", typeof(long));
var jobs_table = data.Tables.Add("InvoiceJobs");
jobs_table.Columns.Add("InvoiceId", typeof(long));
jobs_table.Columns.Add("InvoiceJobCode", typeof(string));
data.Relations.Add("InvoicesJobs", activity_table.Columns["InvoiceId"], jobs_table.Columns["InvoiceId"], false);
output.MailMerge.ExecuteWithRegions(data);

Any advice?
Thanks!

Just FYI I’ve tried to set foreign constraint and assign random values to Activities.InvoiceId (for example, any negative numbers), but it didn’t help.

Hi Steve,

Thanks for your inquiry. Perhaps, you’re using an older version of Aspose.Words; as withAspose.Words v13.2.0, I am unable to reproduce this problem on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v13.2.0 and let us know how it goes on your side. I hope, this will help.

I have used the following code snippet to test your issue. Please find the output PDF file with this post.

Document doc = new Document(MyDir + "statement.docx");

DataSet data = new DataSet("Data");
DataTable activity_table = data.Tables.Add("Activities");
activity_table.Columns.Add("Activity", typeof(string));
activity_table.Columns.Add("InvoiceId", typeof(long));
activity_table.Rows.Add("Opening Balance", 1);
activity_table.Rows.Add("Invoice 192-2A", 2);
activity_table.Rows.Add("Payment on Job 192 from invoice 233161A", 3);
DataTable jobs_table = data.Tables.Add("InvoiceJobs");
jobs_table.Columns.Add("InvoiceId", typeof(long));
jobs_table.Columns.Add("InvoiceJobCode", typeof(string));
jobs_table.Rows.Add(1, "192");
jobs_table.Rows.Add(1, "193");
jobs_table.Rows.Add(1, "194");
jobs_table.Rows.Add(2, "192-2");
jobs_table.Rows.Add(2, "192-3");
jobs_table.Rows.Add(2, "192-4");
data.Relations.Add("InvoicesJobs", activity_table.Columns["InvoiceId"], jobs_table.Columns["InvoiceId"], false);
doc.MailMerge.CleanupOptions |= Aspose.Words.Reporting.MailMergeCleanupOptions.RemoveUnusedRegions;
doc.MailMerge.CleanupOptions |= Aspose.Words.Reporting.MailMergeCleanupOptions.RemoveUnusedFields;
doc.MailMerge.ExecuteWithRegions(data);
doc.Save(MyDir + "out.pdf");

Thank you Tahir! With 13.2 it works like a charm

Hi Steve,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.