Replace "URL Hacking" With Salesforce Actions
Tags: salesforce, lightning, quickaction
Published: 2020-01-22 16:45:36

---
title: Replace "URL Hacking" With Salesforce Actions
published: true
description: A tutorial that teaches the reader how to replace their URL hack buttons with Salesforce Actions.
tags: Salesforce, Lightning, Quick Action
series: Salesforce Lightning
---


For many years Salesforce allowed (though may not have suggested) the auto-filling of fields during object creation using a technique called "URL Hacking". This technique involved creating a Custom List Button on an object, then adding a URL with the ids and values to be filled:
<i>/a03/e?&retURL={!Case.Id}&CF00N2C000001PDmC_lkid={!Case.Account}&CF00N2C000001PDm7={!Case.Contact}</i>

Unfortunately with Lightning Experience this feature has been deprecated as browser tabs were replaced with tabs and sub-tabs housed within a single Salesforce browser window.

All is not lost, though!

Actions are Salesforce's solution to this problem - although they are slightly more time-consuming to set up, they are more robust and provide better functionality than a URL-hacked button. There are currently two kinds of actions available:


<ul>
<li>Global actions can be placed and used from any of your org's objects, therefore they cannot access any object-specific information such as record ids. Global actions are best for automatically creating new records, sending emails, or logging calls.</li>
<li>Object-specific actions can only be added to the selected object's page layout, providing access to fields on the selected object such as record ids and field values. To replace URL-hack buttons we want to use object-specific actions because they most closely resemble this functionality.</li>
</ul>


For this tutorial we're going to walk through creating an object-specific action since that is the most likely choice for the topic:

1. Click Setup and search "Object Manager".
![Search Object Manager](https://thepracticaldev.s3.amazonaws.com/i/hhvbmi9wmv1z05cxlxlz.PNG)

2. Select the parent object in the list (this is the one you're placing the Action on, not the object you're creating).
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/39kmabdlzsdtmfxkdls3.PNG)

3. In the left-hand toolbar click "Buttons, Links, and Actions".
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/vg2hb4ymtdj3zzfow2eb.PNG)

4. Click "New Action" in the top right corner of the window.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/e0vfwu4mjlz9z2l6kmvk.PNG)

5. On the New Action screen update the Action Type to "Create a Record", set Target Object to the object you want to create, and create or select a Label. The Name field will auto-fill based on your Label selection. My Action is set up to create a new RMA, which is a custom object in my company.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/q3zanf6tikcrmcr8xyw2.PNG)

6. Next you will see the Page Layout screen, which works similarly to any object Page Layout. Choose the fields you'd like the user to fill in (or be auto-filled) on the Create New page dialog by dragging them onto/off of the white workspace. Note: Salesforce suggests keeping the number of fields at a minimum to avoid overwhelming your users!
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/7mna2xnj51evq94roxmg.PNG)

7. Saving your page layout will redirect you to the Action details page. To select fields to auto-fill and provide their values, click "New" in the Predefined Field Values related list.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/snjp5s4nq7n2es3fiowc.PNG)

8. In the New Predefined Field Value screen, select the Field you'd like to have auto-filled from the Field Name drop-down. In the formula editor, either enter a hard-coded value or most commonly a field value from the parent object.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/gmhuufp9ew5lb8icgqbq.PNG)

9. Repeat step 8 for all of the fields you want filled.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/xy0hyv3h3b5zhgkpxep8.PNG)

10. The final step is to add the new Action to the page layout of the parent object. Navigate to the Page Layout and drag your action into the Salesforce Mobile and Lightning Experience Actions from the Mobile & Lightning Actions selection.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/uonb06p5tt0b10h54z34.PNG)

11. Confirm the Action shows up correctly on the object detail page*. 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/482yvhc11mkkk6rs2z65.PNG)


*If your Action isn't showing up correctly on the object read the next tutorial in this series titled "Error: Actions Not Showing Up As Buttons On Lightning Pages" (coming soon)

---

If you'd like to catch up with me on social media, come find me over on [Twitter](https://twitter.com/RachSoderberg) or [LinkedIn](https://www.linkedin.com/in/rachelsoderberg/) and say hello!