Loading
Prepare for Email to Become the Default Login ExperienceRead More
Ongoing maintenance for Salesforce HelpRead More
Extend Salesforce with Clicks, Not Code
JSENCODE

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.

Tips

This function is only available in custom buttons and links, and in Visualforce.

Merge Field Example
Merge Field Example

If the merge field foo__c contains <B>Enter the user's name<b>, {!JSENCODE(foo__c)} results in: \u003CB\u003EEnter the user\'s name\u003C\/b\u003E

 
Loading
Salesforce Help | Article