Cert++
Close

JavaScript buttons and their Lightning Experience alternatives

Key Takeaway

JavaScript buttons don't work in Lightning Experience or the Salesforce mobile app, so rebuild them with features Lightning Experience supports, such as quick actions and flow actions.

A JavaScript button is a custom button that runs script code when a user clicks it, a pattern common in Salesforce Classic. In Lightning Experience, app builders rebuild that functionality as an action, and then add the action to a layout so users can see it.

What a JavaScript button is and where it fails

Two settings make a custom button a JavaScript button: Behavior is set to "Execute JavaScript", and Content Source is set to "OnClick JavaScript".

For example, a Detail Page Button on cases can run script that sets the case Status to "New" when a user clicks it.

The REQUIRESCRIPT function is also a sign of a JavaScript button. It returns a script tag for a toolkit such as the Lightning Platform AJAX Toolkit. REQUIRESCRIPT is only available for custom buttons and links with Content Source set to "OnClick JavaScript". In Visualforce, you use INCLUDESCRIPT instead.

Custom buttons that call JavaScript aren't supported in Lightning Experience. Custom buttons with a Content Source of OnClick JavaScript aren't supported in the Salesforce mobile app (also called the Salesforce app) either, so the same button fails in Lightning Experience on desktop and on mobile.

Platform App Builder Study Guide

Checklist progress

0/340Learned

Demonstrate the capabilities and use cases for custom buttons, links, and actions.

0/13

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Platform App Builder studiers.