We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DocIO Mail Merge with nested business object

Hello,

is it possible to do nested mail merge with nested business objects instead of datatables ( I can't use data tables!)  as well?

Does an examples for this scenario exist?

I have a relational object graph, but I can't manage to access the child elements (like customers -> orders)

class Customer
public string CustomerName {get; set;}
public List<Order> Orders {get; set;}
class Order
 public Int OrderNumber {get; set;}

<<BeginGroup:Customers>>
<<CustomerName>>
<<BeginGroup:Orders>>
<<OrderNumber>>
<<EndGroup:orders>>
 <<EndGroup:Customers>>

var Customers = new List<Customer> {new Customer .............}
doc.MailMerge.Execute(Customers)

Instead of getting the orders I will only get : System.Collections.Generic.List`1[MailMergeTest.Api.Order]

Thank you for your kind help.

Marc

4 Replies

DV Divyalakshmi Vasudevan Syncfusion Team March 24, 2015 05:23 AM UTC

Hi Marc,

Thank you for your interest in Syncfusion products.

Yes, it is possible to perform the Nested mail merge with nested business objects instead of data tables.

Please find the online sample to illustrate the same for Nested Mail Merge functionality using Essential DocIO from the below link. Try running this sample and let us know if this helps you.

http://asp.syncfusion.com/demos/web/docio/nestedmailmerge.aspx

Kindly refer the below UG documentation link for more about Nested Mail Merge functionality using Essential DocIO:

http://help.syncfusion.com/ug/wpf/documents/nestedmailmerge.htm

Please let us know in case of any other questions.

Regards,
Divyalakshmi V



MS marc sommer March 28, 2015 11:44 AM UTC

this does the trick:
doc.MailMerge.ExecuteNestedGroup(new MailMergeDataTable("Customers", Customers));

this now works fine except for the following:
for each row in the datasource, a new table is created. How to use an existing table and only append rows to this table?

<<BeginGroup:Customers>>
<<CustomerName>>
<<BeginGroup:Orders>>
Table
TableRow
<<OrderNumber>>
TableRowEnd
TableEnd
<<EndGroup:orders>>
 <<EndGroup:Customers>>



MS marc sommer March 29, 2015 03:01 PM UTC

Very strange behaviour:
If I put the BeginGroup:Orders / EndGroup:Orders MergeFields at the beginning of a table row and at the end of a table row, I get an error message (ApplicationExeption : Group Orders is missing in the source document). If I put additional BeginGroup:Orders / EndGroup:Orders MergeFields anywhere in the document, everything is fine, but looks very ugly and I have to double the group merge fields.

List<Customer> Customers
 Customer
  List<Order> Orders
  

doc.MailMerge.ExecuteNestedGroup(new MailMergeDataTable("Customers", Customers));


Doesn't work (ApplicationExeption : Group Orders is missing in the source document):
{TableStart}
{RowStart}
{CellStart}{MergeField}{MergeField}{CellEnd}
{CellStart}{MergeField}{MergeField}
{CellEnd}
{RowEnd}
{TableEnd}

this is working:
{MergeField BeginGroup:Orders}{MergeField EndGroup:Orders}
{TableStart}
{RowStart}
{CellStart}{MergeField BeginGroup:Orders}{MergeField}{CellEnd}
{CellStart}{MergeField}{MergeField EndGroup:Orders}
{CellEnd}
{RowEnd}
{TableEnd}

Is this behaviour intented? Anyway to avoid this?


DV Divyalakshmi Vasudevan Syncfusion Team March 30, 2015 09:42 AM UTC

Hi Marc,

Thank you for your update.

Kindly make use of the below attached template document to avoid creation of the new table. In the attached Word document we have defined the table start and table end for orders inside the table itself so it will append the each row in the table instead of new table. Kindly follow this structure during mail merge process in order to avoid the creation of new table. Please do find the template document from below link.

Document Link:

http://www.syncfusion.com/downloads/support/forum/118595/Document-1409673625.zip

Please let us know in case of any question.

Regards,
Divyalakshmi V


Loader.
Live Chat Icon For mobile
Up arrow icon