Generate Documents from List View

In the Formstack Documents Managed Package (versions 1.250+), we have built-in buttons for generating documents from a List View for Account, Contact, Lead, and Opportunity objects. For those objects, simply open up your Search Page (List View) Layout and add the Formstack Documents button to the page.

From your List View, you'll be able to select a set of records, click the Formstack Documents button, then you'll be asked to pick your Formstack Mapping (just like when you're merging a single record)

Setup VF Page & Button for Custom Objects

1. Setup a new Visualforce Page under Setup > Develop > Visualforce Pages

Use this code for the page (change "Certificate__c" to match your object name):

<apex:page standardController="Certificate__c" extensions="webm.WebmergeWizardController" docType="html-5.0" title="Webmerge List View Merge" recordSetVar="selectedRecords">
<webm:WebMergeMassMerge records="{!selectedRecords}" combine="false" />

2. Create a new List View Button for your object and select the VF page you just created.

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 > Custom Object, 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

- Content Source: Visualforce Page




3. Add your new button to your Search 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.


List View in Classic (via Javascript Button)

*This is old functionality that is only available in Classic

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

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 Formstack 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 your page 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});
Was this article helpful?
0 out of 0 found this helpful


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


    Ringier AG

  • 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!



  • Jeremy, I've seen some of the other document generation software solutions employ "generate from report" as a way to get around the list view limitation in Lightning.

    Is there any way you think that could work? (For example, create a report that shows new leads from a tradeshow. Then, you can create a welcome letter to all leads on that list). This essentially gives users the same functionality as creating from list view -- and is fully compatible with Salesforce Lightning.

  • Hi Daniel,

    Thanks for the suggestion! We have an APEX API that can be used to generate documents from Reports: (end of article)

  • Hi Jeremy,

    I am currently trialing WebMerge for a client. For the standard letters I have been very pleased.

    Linked to the conversation above, are you please able to provide instructions on how to create a WebMerge document from a Salesforce Lightning Report?

    I have a report for custom objects, which shows all the records related to a particular program within a defined date range. In Salesforce Lightning, the report has a title, a header row, rows of data followed by totals at the bottom. E.g. similar to a PDF invoice for an account - but the data is currently filtered and output by a report.

    Thanks, Katrina.

  • Hi Katrina,

    Are you wanting to create a PDF of the actual report, or are you wanting to create a PDF document for each record that is listed on the report?

  • Hi Jeremy, I want to create one PDF report document containing all the records and totals from the report. (E.g. an activity statement that is sent to a contact, listing all the records revelevant to their specific program.)

  • Hi Katrina,

    We don't have an out-of-the-box way to do that, but you can build a APEX process that could connect to a button and then call our APEX API mergeReport() function. Or you can use the APEX code to query the database for data from the report then use doMerge() to send the data over to WebMerge.


  • Thanks Jeremy, I’ll research these functions and see if I can get something working.

  • I'm getting error while saving the below code in VF Page

     <apex:page standardController="Account" extensions="webm.WebmergeWizardController" docType="html-5.0" title="Webmerge List View Merge" recordSetVar="selectedRecords">
    <webm:WebMergeMassMerge records="{!selectedRecords}" />

    The installed managed class webm.WebmergeWizardController is not visible

  • Hi Jeremy,

    I was trying to save the below apex page

    But i'm getting below error
    The installed managed class webm.WebmergeWizardController is not visible

    webm is the managed package,

    If i remove the webm. then it showing below error message
    Apex class 'WebmergeWizardController' does not exist


  • Hi Saraswathi,

    This issue (not being visible) should be fixed in version 1.251 -- can you please try to update to the latest version from the AppExchange?


  • Thanks

    I will check and let you know.

  • Hi Jeremy Clarke,

    I have updated to version 1.253.

    But i'm not able to generate for the files for the multiple records(Account).

    I have selected more than one account and clicked on the button.
    It's generating file/attachment only for the first record(Account) and i'ts not generating for the remaining records(Accounts).


  • Saraswathi,

    While on our Free plan, we limit you to 1 merge per minute. If you don't think that's the issue, please create a support ticket and we can help you further.


  • Thank you Jeremy Clarke,
    I'm using the trail version

  • Can this doc please be updated for the new state of things? The list view buttons & VF pages exist in the SF App and can be added to LEX lists for the standard objects, but they don't pull up the choice of which mapping to use-- just some blank screens and "Your docs have been merged, but they haven't). You *can* choose records in a list in LEX (as opposed to the 2017 comment above). Do those not work still?


Please sign in to leave a comment.