Adding the Mass Generation Button to Custom Objects

Step 1: In Salesforce Lightning go to Setup>Apex Classes click New

step 2: Define your custom object at the code below and copy it to the Apex Class you just created.

				
					console.log( 'Code is Poetry' );public with sharing class RedirectToGeneration {
    public String message { get; set; }
    public Boolean isSuccess { get; set; }
    public Boolean showMessage { get; set; }
    public List<SObject> objectsList;
    public String objectsIds;

    public RedirectToGeneration(ApexPages.StandardSetController cntlr) {
        message = 'Select one or more Records';
        isSuccess = false;

        objectsList = cntlr.getSelected();
        List<Id> objectIdsList = new List<Id>(new Map<Id, SObject>(objectsList).keySet());
        objectsIds = String.join(objectIdsList, ',');
    }

    public Object redirectToGenerationPage(){
        String previousPageUrl = ApexPages.currentPage().getParameters().get('vfRetURLInSFX');
        Boolean isPrevPageList = previousPageUrl != null ? previousPageUrl.contains('/list?') : false;
        String returnUrl = '/lightning/cmp/doco__documentGenrator?c__recordIds=' + objectsIds + '&c__isPrevPageList=' + isPrevPageList;
        PageReference pgReturnPage = new PageReference(returnUrl);
        pgReturnPage.setRedirect(true);
        return pgReturnPage;
    }
}

				
			

Step 3: Created a VisualForce Page

				
					<apex:page standardController="Custom_Object__c" recordSetVar="accs" extensions="RedirectToGeneration" action="{!redirectToGenerationPage}">
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" rendered="{!showMessage}"> 
        <apex:slds />
        <div class="slds-scope">
            <apex:form >
            </apex:form>
        </div>
    </html>
    
</apex:page>

				
			

Step 4: Create the list button and redirect it to the new VisualForce Page.