The Salesforce Lightning URL Hack is a method for crafting a special hyperlink or script and exposing it via button or formula field. These specially crafted hyperlinks are often used to provide additional functionality and automation to end-users.
- Setting record types for newly created records.
- Pre-populating values on child records created from parent.
- Sending emails with a specific template IDs.
Disadvantage of Salesforce Lightning URL hack button:
- Not officially supported by Salesforce.
- Difficult to modify and/or maintain.
- No native admin UI – Limited to editing a formula or URL string.
- Do not work in Salesforce1 or Lightning Experience.
Solution for Salesforce Lightning URL Hack button in Lightning Experience and Salesforce1:
Some of the features are not supported in Lightning Experience and Salesforce1 like Java Script button, Custom Links, URL Hack button, etc. Instead of creating URL hack button in Lighting Experience, we can create Actions in Lightning.
The creation of related records can be configured to set default values on new records and are available for use in Classic, Lightning, and Salesforce1.
Two primary types of actions:
- Global Actions
- Object Specific Actions.
Global actions are available for use from any feed enabled page. Add common actions to Global Layout to make them accessible on all feed enabled pages. In Classic, this includes the Home tab, Chatter tab, object detail records.
Object Specific Actions:
Create records that are automatically associated with other records. Commonly used to create a contact or opportunity from an account. Available in Classic via the Chatter Publisher.
URL Hack button in Salesforce- Classic:
In this example, create a list button in Contact object. When we click new contact button in the account related list, it will redirect to the new contact record page with some pre- populating values like Account Name, Parent name and Status field (custom field).
Go to Setup -> Contact-> Buttons, Links, and Actions-> New Button or Link. Create a New Hack button and add to the Account layout.
Create a new Account. Now, we can see the New Hack Contact button in the Account related list.
Step 3: Click New Hack contact button.
URL Hack Button in Lightning Experience:
Switch to Lightning Experience and click Object Manager [Symbol] Click Account [Symbol] Click Buttons, Links, and Actions [Symbol] Create new Action and set predefined values which we are pre- populating in contact record
Step 2: Setup –> Object Manager[Symbol]Accounts [Symbol] Page Layouts [Symbol] Edit Layout. Scroll to Quick Action, locate the ‘New Hack Contact’ action and drag to Quick Actions in the Salesforce classic Publisher section of the page layout. Save the changes and open the Account Detail Page.
URL Hack Button in Salesforce1: Action in Salesforce1 is listed along the bottom of the App.