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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DocIO Mail Merge with nested business object

Thread ID:

Created:

Updated:

Platform:

Replies:

118595 Mar 23,2015 06:29 AM UTC Mar 30,2015 09:42 AM UTC WPF 4
loading
Tags: DocIO
marc sommer
Asked On March 23, 2015 06:29 AM UTC

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

Divyalakshmi Vasudevan [Syncfusion]
Replied On 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


marc sommer
Replied On 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>>


marc sommer
Replied On 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?

Divyalakshmi Vasudevan [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;