URL Hacking has remained infamous in the Salesforce space for a while. If you are unfamiliar with the term, it essentially means that you can create a custom button in Salesforce classic that will create a new record, but pre-populated with information from the original record. For example, you could replace the “New” Opportunity button on the account related list page, with a URL hack that pre-populates the new Opportunity with a bunch of account data.
The reason it’s infamous? URL Hacking is a completely unsupported feature, so technically it’s a bit dodgy to use. However, people have used this workaround for many years with no problems. One potential issue URL hacks will face is when an organization decides to switch to the Lightning Experience. Classically custom buttons and URL hacks are not supported in the same way they are in lightning, which means you will run into issues. Introducing Actions…
Actions can be used in various different ways across classic & lightning to efficiently interact with records. There are various types of actions including standard, default, mobile, and customer, for a full overview check out this handy article. For this guide, we are going to be concentrating on custom actions as these enable us to have some fun. There are two types of custom actions.
Global Quick Actions – Global actions allow you to create actions that can sit anywhere. Actions such as creating a record, logging a call and sending emails are available. The key difference here is that these actions can sit on any object in your Org.
Object-Specific Quick Actions – Object-specific actions allow you to carry out very similar functions to global, but they also allow you to update records. The key difference here is that they are created on an object by object basis and can only be used for the object they are created for. This is because the action MAY contain formulas or references that only work with its specific object. These are the actions we are interested in to replace URL hacks, as we want to reference object specific fields.
You can expect to see the actions within the chatter section in classic, or in your highlights panel in lightning…
Creating Object-Specific Actions
Object-specific actions are super easy to create with a standard point and click interface, you can build quick actions in minutes. This is a great step in the right direction, as powerful as URL hacks were, they were fiddly and awkward to create for novice Admins. For this short tutorial, I’m going to be using the same use case as I did on the original URL Hacking tutorial. This is to create a custom object record called “Resource Request” off of an Opportunity, with pre-populated information.
Step 1 – Which Object?
Firstly, we need to decide where this action is going to sit. Actions are placed on the page where you want to create them from, in exactly the same fashion as custom buttons in URL Hacks. For this resource request example, we are going to want to place it on the Opportunity. To access actions, navigate to Setup > Opportunity > Buttons, Links, and Actions > New Action
Step 2 – Create the Action
After clicking on “New Action” you will be greeted with the setup page for creating a new action. From this page, you can create various action types such as creating a record, updating a record, sending an email, among others. To replace a URL hack we want to focus on creating a new record.
From the image on the right, you can see the basic settings needed in order to create the basis of the action. We simply need to define the Type, Target Object, and a label. Step 2 complete!
Step 3 – Action Layout
Once completed and saved, the next step is the create the action layout. You can think of the action layout as a miniature layout that contains the important and required fields needed to create the record. This has major advantages over the older URL hacks, as once clicked, you were taken to the full edit page of a record.
Below you can see a simple mini layout I’ve created which has the core fields I want to show.
Step 4 – Predefined Field Values
Now we have completed the action layout, we can really have some fun. So far we have created a usable action that can be placed on our record page to launch a pop-up box with the fields defined in the layout. However, this doesn’t replace our URL hacks just yet as the main advantage to using them, is pre-defined field values. You can get started by clicking new on the Predefined Field Values section at the bottom of the action layout.
By clicking new, you are able to set the field values in your new record using the standard Salesforce formula editor. This is massively more powerful than URL hacks as you can quickly access fields across all relationships (reducing development time), but also run calculations. For example, you can see below that I have prepopulated the “Project Hours” field on my RR object, from the “Estimated Project Hours” on my Opportunity.
Below you can see an example of a few fields I have added to be prepopulated. Including making the start date equal to the close date + 10.
What this results in upon clicking the action, is a beautifully pre-populated popup box ready to create your new record!
Step 5 – Add to the Layout
The fifth and final step for your new action is to add it to the layout. There is one small quirk here that I would like to address just to prevent any confusion. The section where you add your action to the layout will depend on whether you are using Classic or Lightning.
If you head over to the page layout of your chosen object, you will notice that there is a section for “Quick Actions” as well as “Lightning Actions”. The key difference here is Lightning Vs Classic…
Lightning – These are placed as per the screenshot above which display in the highlights panel in Lightning. You can access these via the “Mobile & Lightning Actions”.
Classic – These are placed in the Salesforce Classic Publisher in the chatter feed section of your layout. You can access these via the “Quick Actions”.
Salesforce will automatically create duplicates of your actions ready to either be slotted into Classic or Lightning. Just ensure that you add them to the correct section on your page layout.
I hope you have enjoyed this article on how to migrate your URL hacks over to quick actions. I’m sure you will agree that with the easy point and click interface, as well as the extra functionality, this is a migration worth doing for yours and your users benefit! It’s also great to get ahead of the game if you are yet to switch over to Lightning.
If you have any questions, let me know in the comments below!