Print this page

Hyperlink function in formula field results in HL_ENCODED text

Knowledge Article Number 000187261
Description When a Hyperlink function is used in formula field and the text field used for the hyperlink text contains line breaks or return characters, the resulting hyperlink breaks and shows as HL_ENCODED_customfieldvalue_

For example, HYPERLINK( ID, custom_field__c) is the formula in a formula field.

The text value in custom_field__c is

"quick brown fox is
quicker than the fox"

instead of  "quick brown fox is quicker than the fox"

In this case, the formula field does not work as a link and appears as 

HL_ENCODED_quick brown fox is
quicker than the fox_HL__blank_HL_

This issue has been published as a Known Issue:

_BR_ENCODED_ markers are not replaced for text formula values used by Apex/Flow/Process when those values are populated in other text/text area field

A slightly different scenario, without the line break, might currently also be seen on Dashboards or Exported Reports:
_HL_ENCODED or _BR_ENCODED_ displayed when formula used as display on Report Export
_HL_ENCODED or _BR_ENCODED_ displayed when formula used as display on dashboard table component and chart
Resolution Currently HYPERLINK function cannot handle line breaks or return characters.

Workaround for this behavior is have create a validation rule on the custom text field to not allow line breaks or return characters, using REGEX function which is the only function available to detect line breaks or return characters in validation rules.

e.g.: OR(REGEX(custom_field__c,".*\\n.*"),REGEX(custom_field__c,".*\\r.*"),REGEX(custom_field__c,".*\\r\\n.*")) 

promote demote