Link is loading an 'Illegal URL'

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
Hi,

We're facing the following challenge with a template field that we're using to display a record name as a hyperlink:

If the name value has a percentage in it, upon clicking on the hyperlink the user is being directed to a blank page with the following message when clicking on the URL:
"Illegal Request

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

It seems that the URL is not getting URL encoded. Percentages are not formatting correctly in the URL. How
 do we fix this?

Any help on this would be greatly appreciated.

Thanks!
Photo of Meryl Flynn

Meryl Flynn

  • 204 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Can you post the template code that you are using? 
Photo of Meryl Flynn

Meryl Flynn

  • 204 Points 100 badge 2x thumb
Hi Rob,

I have to be careful as I'm working with Client sensitive information, but I'll use Contacts and Accounts as an example in the merge fields:

<a href="/{{{Contact__r.Id}}}?jName={{{Account__r.Name}}}&jobId={{{Account__r.Id}}}">{{Contact__r.Name}}({{Contact__r.Code__c}})</a>

In this case, the field is on a Junction object which is referencing both Account and Contact objects. I hope this helps.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I'm pretty sure that the URL is breaking on the account.name field.  If you URL-encode that field it will probably work.   That looks like this: 

{{#urlEncode}}{{{Account__r.NamecompanyName}}}{{/urlEncode}}
Photo of Meryl Flynn

Meryl Flynn

  • 204 Points 100 badge 2x thumb
Rob - this worked. Thanks so much for your help!