2

I embeded an url in email template, like this:

http://www.abc.com?param1={!Account.Name}

Sometime the account name would contain a blank, such as Allen li. Then we will get an url like this: http://www.abc.com?param1=Allen li

That's a problem because the link will be divided. I don't want fix this by apex code. Is there a solution about this?

2
  • 1
    Have you tried using the SUBSTITUTE expression and replace ' ' whitespace with %20 which is URL encoded value for whitespace? Mar 24, 2014 at 3:37
  • We can't use formula function in email template.
    – Allen Li
    Mar 24, 2014 at 10:34

2 Answers 2

6

You can use the URLENCODE formula function.

Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21.

{!URLENCODE(text)} and replace text with the merge field or text string that you want to encode.

i've just tested this with a Text based Email Template and it seems to work just fine. The following...

http://www.abc.com?param1={!URLENCODE(Account.Name)}

Gives...

http://www.abc.com?param1=Burlington+Textiles+Corp+of+America
1
  • Your welcome, go Visualforce functions! :-) Apr 3, 2014 at 6:58
1

You can create formula field where you will replace all unwanted characters and build link

You must log in to answer this question.

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