Lightning Layout Tricks: Quick Action Hack

Quick Actions are a powerful tool that allow users to quickly create records with the click of a button, prefilling values from the current record.  However, in some instances, the object you wish to create does not appear in the ‘Target Object’ menu.

In the example here, I want to create a new ‘Dependency’ record from my ‘Component’ object, however when I go to create a quick action these are my only options:

The reason for this behavior has to do with the relationship types.

Components are detail in a master-detail relationship to Object A and Dependencies are detail in a master-detail to Object A as well.  As Salesforce notes in this help article:

If you create an action on a detail object in a master-detail relationship, the action’s target object can’t be a different detail object of the same master.

For example, master object A has two detail objects, B and C. You can create actions on object A with B or C as the target object. However, when creating an action on object B, the target object can’t be object C, because B and C have the same master. There are two ways to work around this to create an action on B using C as the target object.

Bummer. We aren’t going to let that stop us though – enter the Quick Action Hack!

To create the quick action hack we’ll use a combination of custom fields, an Update Record Quick Action, and Process Builder to simulate a Create Record Quick Action.

In its simplest form, we only need a single checkbox custom field on the Component object (Source Object) called ‘Create Dependency (Target Object) Record’ but do not add it to the Source Object page layout.

Create an Update Record Quick Action on the Source Object, only add your checkbox to the page layout, and predefine that checkbox as true.

Now, create a new Process using Process Builder, that when the checkbox equals true, creates your target object record (in my case Dependency), and passing all desired values from the Source Object (Component) to the Target object (Dependency).  Add a Record Update step to your Process to return your checkbox to False so the Quick Action can be used again.

Now you only have to add your Update Records Quick Action to your Page Layout and users get the ability to click a button and create their target record.

Options & Considerations:

If you want users to see more fields in the Quick Action you can create those fields on your Source Object and simply not add them to the page layout.  Instead, add all of those fields to your Update Record Quick Action layout, users can populate them when they click our fake ‘Create Target Object’ button, and map all of those fields in Process Builder.

The end user will have the exact same experience as a standard ‘Create Record’ Quick Action and will have no idea you are using your super admin powers to beat the system!

As far as considerations and limitations – obviously adding a ton of custom fields may not be a practical solution, as they’ll show up on reports and things and could be confusing to users.  Where possible, I would limit this to a checkbox and/or only a handful of custom fields.



Leave a Reply

Your email address will not be published. Required fields are marked *