cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Mass Button in Lightning

Topic

How to create Mass Button in Lightning

Instructions

Creating MASS button in Lightning:
We recommend to create a "MASS via List View" button in Lightning. Attached you will find a sample using the Opportunity object. Just replace the opportunity object with the desired object, and you should be able to use MASS via List View in Lightning

1. Go to the visual force pages in Salesforce setup and create new visual force page:
User-added image
2. Give it a name “MassLightning” or “MassLoopButton” for example and paste the attached code below in the Apex code area.
User-added image

3. Navigate to the Drawloop Admin Tab and click “Create Advanced Buttons”
4. Name your button for MASS
  • Select the starting object
  • Select Type as Mass Report Button
  • Select “Create button”
5. Change the Content source to the Visual Force page – your Mass button VF page will populate in “Content”
 User-added image
User-added image
  1. Add to your layout in next window.
  2. Return to your Lightning Experience.
  • Navigate to your object.
  • Select All on view list. – See the button in the top right.
  •  Select a few records and Select mass run button.
  • Select the DDP and Run.
 User-added image

Additional Information

Lightning Text Sample: Replace "Opportunity" with starting object.
 
<apex:page standardController="Opportunity" recordSetVar="units">
<script src="/soap/ajax/26.0/connection.js"> </script>
<script src="/support/console/26.0/integration.js"> </script>

<apex:dataTable value="{!selected}" var="un">
    <apex:column >
        <apex:outputLabel styleClass="ids">{!un.Id}</apex:outputLabel>
    </apex:column>
</apex:dataTable>
<style>
.ids{visibility : hidden}
</style>

<script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function(event) { 
        var elems = document.body.getElementsByClassName("ids");
        var ids = new Array();

        for (var i = elems.length - 1; i >= 0; i--) {
            ids[i] = elems[i].innerHTML;    
        }
        console.log(ids);
        if (!ids || ids.length < 1)
            alert('Please select at least one record.');
        else
        {
             var instanceName = window.location.hostname;
            var newLocation = '/apex/loop__jobqueuestatus';
            console.log(instanceName+newLocation);
            var redirectUrl = '/apex/loop__masslooplus?';
            
            redirectUrl += '&recordIds='+ids.join(',');
            redirectUrl += '&sessionId={!$Api.Session_ID}';
            redirectUrl += '&retURL='+newLocation;
            if (sforce && sforce.one && sforce.one.navigateToURL) {
    sforce.one.navigateToURL(redirectUrl);
} else {
    window.location.href = redirectUrl;
}
        }
    });
      
</script>
</apex:page>

Labels: (2)
Version history
Revision #:
14 of 14
Last update:
a week ago
Updated by: