MailMergeField renders placeholder instead of content when value is empty

Posted by: greg on 14 May 2024, 8:53 pm EST

    • Post Options:
    • Link

    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?

  • Posted 16 May 2024, 2:36 am EST

    Hi Mark,

    We were able to replicate the issue on our end and have escalated the same to our development team with the Case ID: AR-33486. We’ll let you know of any updates regarding the same.

    Regards,

    Anand

  • Posted 17 May 2024, 12:28 am EST

    Hi Greg,

    You can set the Mail Merge Field’s value to the expression ‘=iif([@MailMergeFieldValue]=“”," ",[@MailMergeFieldValue])’ and it should work as expected.

    Please find attached a sample implementing the same.

    Regards,

    Anand

    MailMergeReports.zip

  • Posted 17 May 2024, 12:37 am EST

    Hi Anand,

    Thanks. While setting the value to a whitespace character does avoid the issue in this case, I think the handling of MailMergeFields should still be reviewed. In some situations it would be undesirable to have additional whitespace in the output.

    In my opinion the MailMergeField name placeholder should never appear in the output.

    Regards,

    Greg

  • Posted 17 May 2024, 7:02 am EST

    Hi Greg,

    Yes, the developers have acknowledged this as a bug and a fix for the same is expected to be released with ActiveReports v18.1.

    Regards,

    Anand

  • Posted 25 June 2024, 1:52 am EST

    Hi Greg,

    This issue has been fixed in ActiveReports v18.1, you can download the same from here https://developer.mescius.com/activereports/download-version-history

    Regards,

    Anand

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels