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 objectsList;
public String objectsIds;
public RedirectToGeneration(ApexPages.StandardSetController cntlr) {
message = 'Select one or more Records';
isSuccess = false;
objectsList = cntlr.getSelected();
List objectIdsList = new List(new Map(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
Step 4: Create the list button and redirect it to the new VisualForce Page.