Merge Field
MergeField is a Field element containing a reference to a data field by its name. When a template document is mail merged with the values from a data source, the data field information replaces the merge field. More information on the mail merge feature is available in the respective article: Mail Merge.
Field Syntax
This is how the syntax of a Merge field looks like:
Syntax |
---|
{ MERGEFIELD FieldName [Switches]} |
The syntax of a merge field is demonstrated in Figure 1.
Figure 1: Merge Field Code Syntax
"FieldName"
The name of a data field listed in the header record of the selected data source. The field name must exactly match the field name in the header record.
Switches
Switches are a way for the code fragment to specify formatting for the result of the field. More information is available in the Syntax and Switches section of the Fields article.
The possible switches for a Merge field are:
Switch | Description |
---|---|
\@ "Date-Time Picture" | Specifies a date format if different than the default format. |
\* Format Switch | Specifies the appearance of the number if different than the default format. |
\b | Specifies text, which shall be inserted before the Merge Field in case the field is not blank |
\f | Specifies text, which shall be inserted after the Merge Field in case the field is not blank |
\m | Specifies that the MergeField field is a mapped field |
\v | Enables character conversion for vertical formatting |
Inserting
Inserting a Merge field is easily achieved through the RadFlowDocumentEditor's InsertField() method. It accepts code as first argument and result as second argument.
Example 1: Insert Merge field
editor.InsertField("MERGEFIELD First_Name", "«to be updated»");
Example 2: Insert Merge field with switches
editor.InsertField("MERGEFIELD First_Name \b \"Mr. \" \f \". \"", "«to be updated»");
Example 3: Insert Merge field with a Date-Time format switch
editor.InsertField("MERGEFIELD Date_Time \@ \"MM/dd/yy\"", "«to be updated»");