GetMergeFieldNames - Is there a method returning array of real IWMergeField fields instead names only
«BeginGroup:ASSE»
Name: «Text:NAME»
Desc: «Text:DESC»
Type desc: «Text:TYPE_DESC»
«EndGroup:ASSE»
«BeginGroup:DIDX»
Name: «Text:NAME»
Extension: «Text:EXT»
«EndGroup:DIDX»
- key is the group name - null or string empty in case of no group nor table, at document level
- value is the list of WMergeField defined in the group or document (but not in a group)
- start replacing variables group-by group
- replace variables defined at document level (no group nor table)
- collect document mergefield again
- the list of items remaining in the mergeFieldsDictionary are the variables that couldn't be replaced, so we can inform the user with specific warning
- we have the same key for BeginGroup and EndGroup mergefield, without the information about which field is begin and which is end
- we don't know which mergefields belongs to a group or another
- have mergefield items (WMergeField) collected in a
Dictionary < string, List , with a group with name null or "" (string.Empty) to identify document-level> > - Call MailMerge replace execution for all group
- Call MailMerge.Execute replace management for mergefield in "document level" group only, to keep those not replaced but belonging to other group untouched
- Collecting all remaining mergefield in the same
Dictionary < string, List you can have all not replaced mergefield for each group and document.> >
Yes, you can remove the empty group which contain empty merge fields by enabling RemoveEmptyGroup property.
Could you please provide us more details about what the not replaced merge fields actually meant in your requirement (“variables that couldn't be replaced, so we can inform the user with specific warning”):
1. Whether you need to get field name which not have DataColumn (column not defined) in the DataTable (Data structure used for mail merge)?
2. Whether you need to get field name which contains empty value (empty string or null in data) for the merge field?
Also, please share the details about the data structure which used at your end for your requirement:
1. Whether you have only one row for each data table ?
2. Whether you have multiple rows (records) for each data table and need to get different field name and their group which not merged for each iterations.
Regarding how can I share this with you ?
Could you please share us the below things from your end. This will be more helpful to check further on your requirement and provide you the appropriate solution at the earliest.
1. Sample application or code snippets along with the template Word document.
2. Dataset used at your end to perform mail merge.
Note: If you have any confidential data in your Word document and dataset, please replace with some dummy data and provide us the same. We just need your details to check on your working scenario.
You may upload the attachment directly in the forum, or mail it to [email protected] with forum Id as subject.
|
|
Regards,
Group1 (PRIG)
«BeginGroup:PRIG»
Name:
«Text:NAME»
Desc:
«Text:DESC»
Note:
«Text:NOTE»
«EndGroup:PRIG»
Group1 (PRIG)
Name:
AAA
Desc:
«Text:DESC»
<- Should beDesc: as column is present in DataTable, value null
Note:
«Text:NOTE»
Name:
BBB
Desc:
«Text:DESC»
<- Should beDesc: as column is present in DataTable, value is "" (string.Empty )
Note:
«Text:NOTE»
Name:
CCC
Desc:
ccc
Note:
«Text:NOTE»
If the replacement for null or string.Empty will be fixed, maybe the need to have real WMergeFields instead names can be cancelled: our need to have WMergeField instance was to have the chance,if a mergefield is not replaced, to understand its belonging group to inform the user properly, but checking management better we found out that maybe it's not necessary as each mergefield in a group in case of multiple rows in related DataTable is "duplicated" for each row, so if we read the document before any management and collect all mergefield to use later for checks -> after replace of a group, the starting mergefield is no longer present as it's "cloned" for each row.... so the check we want to perform is not possible. We can check mergefield names belonging to a group versus DataTable column names to advice user.
I've sent our helper class in a private mail.
- 6 Replies
- 2 Participants
-
GB Giacomo Barbieri
- Feb 4, 2019 02:11 PM UTC
- Feb 8, 2019 11:56 AM UTC