Loading
Prepare for Email to Become the Default Login ExperienceRead More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Extend Salesforce with Clicks, Not Code
REQUIRESCRIPT

REQUIRESCRIPT

Returns a script tag with URL source that you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits.

Use

{!REQUIRESCRIPT(url)} and replace url with the link for the script that is required.

For the AJAX Toolkit:

{!requireScript("/soap/ajax/13.0/connection.js")}

Returns:

<script src="/soap/ajax/13.0/connection.js"></script>

Tips

  • Use global variables to access special merge fields for s-controls.
  • Use this function when creating custom buttons or links where you have set Behavior to "Execute JavaScript" and Content Source to "OnClick JavaScript" because the script tag must be outside the OnClick code.
  • This function is only available for custom buttons and links that have Content Source set to "OnClick JavaScript."
  • When working in Visualforce, use INCLUDESCRIPT instead.
Custom Button Example
Custom Button Example
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var c = new sforce.SObject("Case");
c.id = "{!Case.Id}";
c.Status = "New";
result = sforce.connection.update([c]);
window.location.reload();

This example sets the Status of a case to “New” whenever a user clicks a custom button from the case detail page. To set up this code in your organization, define a custom button for cases that has the following attributes:

  • Display Type is “Detail Page Button”
  • Behavior is “Execute JavaScript”
  • Content Source is “OnClick JavaScript”

Next, paste this example code into your custom button definition and add it to your case page layouts.

 
Loading
Salesforce Help | Article