Play Games

Search This Blog

Wednesday, December 4, 2013

How to escape special characters in formula?(or) How to escape special characters in javascript written in salesforce?

When we are writing  formulas or javascript code, if the values contains special symbols like aphostrope('),&(ampersand) etc sometimes we won't get expected results.

For example

account name contains O'Henry.Notice that  ' is a special character.When ever u r writing javascript if we write {!account.name}.It will give an error.



So to escape special symbols use JSENCODE function.


JSENCODE() :

                              Encodes text and merge field values for use in javascript by inserting escape characters ,such as a backslash( \ ), before unsafe javascript characters ,such as the apostrophe ( ' ).

Use:

              {!JSENCODE(text)}   and replace text with the merge field  or text string that contains the unsafe javascript characters


No comments:

Post a Comment