How To: Select Record when Copying to a Different Record Type
July 5, 2020
How to: make the Super Clone Pro Edit Page redirect back to itself after save
November 12, 2020

Submit a Queueable to Clone Records

Below is an example that will submit a Queueable job to clone using Super Clone Pro.

Visualforce

<apex:page standardController="Account" extensions="accountCloneController" lightningStylesheets="true">
    <h1>
        Clone: {!account.Name}
    </h1>
    <apex:form>
        <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
        <apex:commandButton action="{!saveClone}" value="Save Clone and Return" immediate="true"/>
    </apex:form>
</apex:page>

Controller extension

public class accountCloneController {
    Account sObj;
    public accountCloneController(ApexPages.StandardController con) {
    sObj = (Account) con.getRecord();
    }

    public pageReference saveClone() {
        if (sObj != null && sObj.Id != null) {
            System.enqueueJob(new accountCloneQueueable(sObj.Id));  
            return new pageReference('/' + sObj.Id);  
        }
        return null;
    }
}
public class accountCloneQueueable implements Queueable {
    Id recId;
    public accountCloneQueueable (Id recId) {
        this.recId = recId;
    }
    public void execute(QueueableContext context) {
        lcrm_scp.ScpApi.clone('AccountClone', new set<Id>{recId});
    }
}

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
Read more