I have a requirement where on clicking on Lightning Quick Action on detail page of custom object will open a pop up asking "wheter to clone?", if user clicks Yes button in the pop up, clone event should fire showing the values of the record be displayed in edit modal pop up along with Save and cancel button (when save button is clicked a new record is created).

If user clicks No button on the pop up of  "wheter to clone?" then user will go through New record create flow (like record type selection then Create New record modal pop up).

Can you please guide me how to achieve this functionality?

Thanks in advance.

1 Answer 1


In order to achieve this functionality, you will need to do use an aura component which implements the force:hasRecordId and force:lightningQuickAction interfaces.

You will need to build the "Would you like to clone?" Yes/No part of the user interface within the aura component. When the user makes their selection, you must use the force:createRecord component (See Documentation here). If the user selects yes, then you will need to prompt them for record type selection, then set the default values from the current record. It might be wise to use a field set to determine which fields you want to clone.

Here is an example using the force:createRecord where you set default values:

var createAcountContactEvent = $A.get("e.force:createRecord");
    "entityApiName": "Contact",
    "defaultFieldValues": {
        'Phone' : '415-240-6590',
        'AccountId' : '001xxxxxxxxxxxxxxx'

In order to fetch the record types, you must do something like this:

 options="{! v.recordTypeOptions }"
 value="{! v.selectedRecordTypeId }"

private static List<RadioOption> getRecordTypeValues(String objectName) {
    list<RadioOption> returnValue = new List<RadioOption>();
    List<Schema.RecordTypeInfo> recordtypes = Schema.getGlobalDescribe().get(objectName).getDescribe().getRecordTypeInfos();
    for(RecordTypeInfo rt : recordtypes) {
        if(rt.getName() != MASTER && rt.getName().trim() != '' && rt.isAvailable()) {
            RadioOption option = new RadioOption();
            option.value =  rt.getRecordTypeId();
            option.label =  rt.getName();
    return returnValue;

public class RadioOption {
    public String value {get; set;}
    public String label {get; set;}
  • Thanks for the reply and my sincere apologies for not replying quickly. I have implemented as per you instructions and able to achieve Clone, but while trying for New record createAccountContactEvent.fire() is not giving the option to select Record Type, by default it is selecting the record type on details page record type on which we were clicking the "whether to clone". So directly getting landed on New object creation screen rather than record selection screen, is there any way we can get the record selection screen. Thanks in advance
    – getty
    Commented Apr 20, 2020 at 17:55
  • You must build the record type selection, then fire the createRecord event. I have added the apex up above to describe how to fetch the recordtypes. Commented Apr 20, 2020 at 18:14
  • I cannot add radiogroup in the Modal pop up of 'whether to clone", as it might confuse user while they want to go with clone option
    – getty
    Commented Apr 21, 2020 at 12:06
  • Got it, I need to hide radiogroup in the component. sfdcmonkey.com/2017/05/09/… Need to set radiogroup instead of list.
    – getty
    Commented Apr 21, 2020 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .