Generate Documents from List View

In addition to generating documents from specific records in Salesforce, you can also generate documents from a List View of records.  To do this, you'll need to:

1. Setup a List View button

Standard Object: Under Setup > Customize, pick the object you want to add the button to and go to the Buttons, Links and Actions page. 

Custom Object: Under Setup > Create > Objects, pick the object that you want to create the button for and scroll down to the Buttons, Links, and Actions section.

Go ahead and create new button. 

- Type: List View Button

- Behavior: Execute Javascript


2. Add Javascript for the button

To trigger the merge, you'll need to add this javascript:

var records = {!GETRECORDIDS($ObjectType.Account)};
sforce.apex.execute("webm.WebmergeGenerator", "generateDocumentBatchJS", {
    sfObjectIds: records,
alert('The documents have been generated!');

To find the "Mapping ID" (wmMappingId), open up the WebMerge Mappings tab and Edit one of your mappings.  In the URL of the page, you'll find the ID you need to use.  Make sure to edit the Object Name (ie "Account") to match your object type.



3. Add button to the Page Layout

To add your button to the List View page, open up your Search Layouts and then find the List View layout.  Click edit and you'll see an option to add your button to the layout.



Other Available Functions

  • generateDocumentJS(wmMappingId, sfObjectId, sfObjectName)
  • generateDocumentBatchJS(wmMappingId, sfObjectIds, sfObjectName)
  • generateDocumentBatchCombinedJS(wmMappingId, sfObjectIds, sfObjectName)



Send Data to Same Document

If you'd like to send all records to the same document, you can setup javascript to send over the data directly to your document (without needing a Mapping) like this:

var records = {!GETRECORDIDS($ObjectType.Account)};

var accounts = sforce.connection.retrieve('Id,Name,Phone,BillingStreet', 'Account', records);
accounts = JSON.parse(JSON.stringify(accounts));
$.post('', {'accounts':accounts});
Have more questions? Submit a request


  • Avatar
    CH Digital

    This is a great functionality, but JS buttons are no longer supported in Lightning - do you have a workaround for that?


    Ringier AG

    Edited by CH Digital
  • Avatar
    Jeremy Clarke

    Hi Corinne,

    Unfortunately, since Lightning doesn't allow for you to select multiple records from list views anymore either, we don't have a good workaround. If you have any ideas, please let us know!



Please sign in to leave a comment.
Powered by Zendesk