Showing results for 
Search instead for 
Did you mean: 

Drawloop - Create Mass Button in Lightning


How to create Mass Button in Lightning


Creating a Mass Button in Lightning:
Below is a Visualforce page sample referencing the Opportunity object in the ‘standardController’. Replace the Opportunity object with the desired object's API name.

 See Additional Customization Configurations section for additional parameters.
<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>
.ids{visibility : hidden}

<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;    
        if (!ids || ids.length < 1)
            alert('Please select at least one record.');
             var instanceName = window.location.hostname;
            var newLocation = '/apex/loop__jobqueuestatus';
            var redirectUrl = '/apex/loop__masslooplus?';
            redirectUrl += '&recordIds='+ids.join(',');
            redirectUrl += '&sessionId={!$Api.Session_ID}';
            redirectUrl += '&retURL='+newLocation;
            if (sforce && && {;
} else {
    window.location.href = redirectUrl;

1. Create a new Visualforce page:
    1. Navigate to Salesforce setup
    2. Quick Find search: Visualforce Pages
    3. Click ‘New’
User-added image

             iv. Create a unique name “MassLightning{object}”.
              v. Checkbox: ‘Available for Lightning Experience’.
             vi. Paste the sample into the ‘Visualforce Markup’ Section.
            vii. Add the desired object API name for the ‘standardController’.
           viii. Click Save.

User-added image

 2. Create a New Button:
    1. Navigate to Salesforce Setup:
    2. Select Object from ‘Object Manager’.
    3. Select ‘Button, Links, and Actions’ section.
    4. Click New Button or Link
User-added image

3. Button Configuration:
    1. Create Label Name.
    2. Display Type: List Button with Display Checkboxes.
    3. Behavior: Select desired behavior.
    4. Content Source: Visualforce Page
    5. Content: Select the created Visualforce Page from the list.
    6. Click Save.
User-added image

4. Add button to the layout:
    1. Navigate to Salesforce Setup:
    2. Select Object from ‘Object Manager’.
    3. Select ‘Search Layouts’ or 'Search Layouts for Salesforce Classic' Section.
    4. Select ‘Edit’ on the List View Layout.
User-added image
User-added image
  1.    v. Select the button from the ‘Available Buttons’ list.
  2.   vi. Add it to the ‘Selected Buttons’ list.
  3.  vii. Click Save.
User-added image

5. Executing Mass via List View:
    1. Navigate to the Object List View.
    2. Select desired records.
    3. Click the List View Button.
    4. Select DocGen Package and Delivery Option.
    5. Click Run.
User-added image


Additional Information

Additional Customization Configurations:

Parameter Documentation: Click Here

Add additional parameters below the {'redirectUrl += '&sessionId={!$Api.Session_ID}';} line.

Email with Mass:
  1. If the delivery option is Email, a contact field will need to be configured in the Visualforce page.
      1. redirectUrl += “&contactfield=APINAME_OF_FIELD”;
      2. Replace the APINAME_OF_FIELD with the desired contact field API.
Specify Document Packages and Delivery Options:
  1. To specify Document Packages and Delivery Option, add the following line and parameters.
      1. redirectUrl += "&ddpIds=PACKAGE_ID&deploy=DELIVERY_ID";
      2. Replace the PACKAGE_ID & DELIVERY_ID with the desired record ids.
Run Automatically:
  1. To bypass the user selection page, add the &autorun=true parameter.
      1. redirectUrl += "&autorun=true";
User-added image

Labels: (2)
Version history
Revision #:
202 of 206
Last update:
3 weeks ago
Updated by: