In the FieldMergingArgs parameter I can’t see a reference to the row/record the field currently being merged in. The end result I would like to achieve is to be able to access the entire dataset that is being used to perform the merge if possible.
My use case is that I’m trying to dynamically insert a table (variable columns/rows) at the point of the merge field. There are examples I’ve found to understand how this can be acheived, however my challenge is the column information (and the row data) is included in the XML data that is part of the mail merge.
e.g.
{Grid title="recipients"}
{Columns}
{Column fieldtype="String"}
{DataIndex}organisationName{/DataIndex}
{Text}Name{/Text}
{/Column}
{Column fieldtype="String"}
{DataIndex}recipientType{/DataIndex}
{Text}Type{/Text}
{/Column}
{/Columns}
{Items}
{Item}
{Value name="organisationName" fieldtype="String"}Organisation One{/Value}
{Value name="recipientType" fieldtype="String"}Subscribed{/Value}
{/Item}
{Item}
{Value name="organisationName" fieldtype="String"}Organisation Two{/Value}
{Value name="recipientType" fieldtype="String"}Regulator{/Value}
{/Item}
{/Items}
{/Grid}
The XML structure can be tidied/simplified further, however the issue is still present.
Is what I’m wanting to do possible and/or is there a better way of doing this? Perhaps an alternative approach is prior to running the mail merge actually creating the tables in the document based on the XML data with the correct merge fields entered and then running the mail merge.
Hi Chris,
Thanks for your inquiry. We have logged your requirement in our issue tracking system as WORDSNET-13980. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for any inconvenience.
Best regards,
Hi Chris,
Regarding WORDSNET-13980, our product team has completed the work on your issue and has come to a conclusion that they won’t be able to implement the fix to your issue. Your issue (WORDSNET-13980) has been closed with ‘Won’t Fix’ resolution.
Chris:
I’m trying to dynamically insert a table (variable columns/rows) at the point of the merge field.
If you want to populate table at the point of the single merge field, the data source should provide entire table content (column titles and rows) for such mergefield, e.g. in xml or json format.
It allows to populate table with IFieldMergingCallback.
However, the mail merge is not designed to populate dynamic table columns.
Best regards,
Thanks for the feedback and suggestion. I’ll look into that.
Is it possible to hide a column in a table based on a merge field condition/value? I’m expecting that this isn’t possible as presumably you’d need to cross cell boundaries with the merge field?
Hi Chris,
Thanks for your inquiry.
There doesn’t seem to be a way in Microsoft Word to show/hide a table cell. However, if your goal is to hide all content contained inside a particular cell, you can wrap cell content in an IF field and based off a condition you can hide the content in the output. I have attached a sample document that demonstrates hiding/showing a cell content using IF field.
Alternatively, in the IFieldMergingCallback method, you can get a reference to mergefield and then ascend to Table Cell using the following method:
Node.GetAncestor Method (NodeType)
And then remove Cell using Cell.Remove method.
Best regards,