I'm trying to build a custom link formula that will return two different URLs depending on the value in a field. When I quote the URL string within the formula function, it becomes URL encoded when it is evaluated. When I come to click the link in the layout, I get the following error:

"You have sent us an Illegal URL or an improperly formatted request."

The custom link formula looks like this:

    ISBLANK( Account.AccountNumber ),

I'd expect this to return the quoted URL strings as the link URL, however the string gets URL encoded somewhere along the way, and the link that this actually produces looks like https%3A%2F%2Fexample-blank.com%2Fpage.html%3Fid%3Dblank, and is why the illegal URL error is being thrown.

How do I include the full URL within the function without it becoming URL encoded?

Alternatively, how do I achieve my desired result of dynamically linking users to two different sites in a Lightning compatible way?

1 Answer 1


Make use of URLFOR function in formula builder to do so:-

{! URLFOR( "https://example-blank.com/page.html?", null, [id=Mission__c.Id] ) }

to build effective URL for your custom link.

Read more here:- Constructing Effective Custom URL Buttons and Links

  • you might want to clarify that URLFOR only works in This function is only available in custom buttons, links, s-controls, and Visualforce pages. - OP seems to suggest he is using a schema formula field
    – cropredy
    Commented Jun 12, 2020 at 1:23
  • In this case, I was using building a formula for a custom link, so the solution works fine.
    – Garywoo
    Commented Jun 15, 2020 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .