Posted 14 May 2024, 8:53 pm EST - Updated 14 May 2024, 8:55 pm EST
We’re using the FormattedText control in an RDLX report in AR17.
We’re using the MailMergeField functionality to dynamically compose the content of the field.
For example, we want to display the FirstName field and optionally display the MiddleName field prefixed with a delimiter if the MiddleName field contains a value.
We create two MailMergeFields. The first has its value set to the FIrstName field.
=First([FirstName], "ReportData")
The second has its value set to the following expression:
=IIF(IsNothing(First([MiddleName], "ReportData")), "", " (" & First([MiddleName], "ReportData") & ")")
Finally, we include the two merge fields in the html content of the control.
<Body>
<div>
<span><%FirstNameMerge /%></span>
<span><%MiddleNameMerge /%></span>
</div>
</Body>
In general this approach seems to work. If the data contains a firstname and middlename then rendered output is
FirstName (MiddleName)
However the problem occurs if there is no middlename in the data. The output becomes:
FirstName <%MiddleNameMerge/%>
The problem seems to be that when a merge field value resolves to an empty string, the merge field placeholder is not replaced.
If I change the middle name merge field expression to
=IIF(IsNothing(First([MiddleName], "ReportData")), "xxx", " (" & First([MiddleName], "ReportData") & ")")
Then the resulting output is
FirstName xxx
Is there a reason why merge fields cannot resolve to an empty string? Is this a bug in the merge field handling?