Prepopulating fields using URL hacking – Part 3: Handling Special Characters

URL Hacking Series
Prepopulating fields using URL hacking – Part 1: The Basics
Prepopulating fields using URL hacking – Part 2: Prepopulating custom fields
Prepopulating fields using URL hacking – Part 3: Handling Special Characters
Prepopulating fields using URL hacking – Part 4: Passing in the Record Type
Prepopulating fields using URL hacking – Part 5: Multi-Select picklists

In the last couple of articles in this series, we looked at the basics of using URL parameters to pre-populate standard and custom fields. Emboldened by my expertise on Salesforce URLs, I tried the following :

Here, the highlighted ID in the URL is the ID of my custom field textbox, as discussed in the last article. I was expecting the value “Text&Text” to be populated into my custom field. Instead, what did I get ?


So what happened to the “&Text” part of the string ? To understand, you need to understand URL encoding. When you paste a URL in a browser, certain characters, such as &, /,. % etc. denote special meaning. For example, the ampersand(&) is used to seperate multiple parameters being passed via the URL. However, when the value you are trying to pass contains one of these special characters, it needs to be “URL encoded”. Basically, you replace the special character with "%” + the hexadecimal ASCII value of the character.

Let’s take an example- the hexadecimal value for the ampersand(&) character is 26. So, let us change our URL slightly to this :

Voila, the complete value is now available :


You can find a complete list of the hexadecimal values for all the characters here : Based on this, I can see that the ASCII-hex value for “%” is 25, that for “$” is 24, and that for the capital letter “A” is 41. Let’s just add these values to the URL and see what happens :

Here’s the result -


As you can see, the percentage sign %, dollar sign $, and letter A, all now display correctly.

In summary, whenever you are passing in values via salesforce URLs, always try to URL Encode them by replacing any special characters with their URL encoded values to avoid unexpected results.


  1. What if you want to pass a multiline text field that has an address, say:
    555 W. 5th St.
    Lubard, CA 90218

    via a URL and you want to keep the line breaks, so that the address populates into a multiline text field on the receiving page?

  2. Thank you for your comment.
    The ASCII-Hex value for newline is %0D%0A. I tried the below URL on my account object and it did indeed add line breaks to the "Description" field -

    Try it out and see if it works for your case... and be sure to switch the IDs to real account IDs in the URL.

  3. Hi! What if you are passing in a variable (i.e. Account Name) rather than hard-coded text and the account name has a special character? I can't figure out how to make this work!