Day: October 17, 2018

Clone Any SObject Record With Lightning Component

In this blog, I am going to show how to clone the record using lightning component quick action. The same functionality can be implemented by using even quick actions without having component also. But this component will be used to clone any object single record.

Step 1: Lightning Component 

Here is the complete code for the quick action.

Apex Class

Lightning Component

Step 2: Create a Quick Action

now create a new quick action as shown below

Step 3: Add the Action to the page layout

Now add the quick action to the page layout Salesforce Mobile and Lightning Experience Actions section. After adding the quick action, you can able to see them on the page layout.


Now when you click on the Custom clone button it is going to clone the record.


Lightning Component Clone with Related Records

In this blog, I am going to explain a simple quick action lightning component that will clone the records and its related data also. In this example, I am controlling which all objects are allowed to as part of the cloning is through the custom metadata data types.

These are the records for metadata 

Apex Class

Lightning Component 





Creating Quick Action 

You will be able to create quick action with the above components shown below.Go to the object manager and create a quick action as shown below.

After saving the action, add this action to the page layout. this component we can reuse it on any object.

Once the user clicks on the clone button its will clone the parent and all child records data along with relationship as shown below.