Implementing WebMerge for Salesforce Using Apex

Implementing WebMerge for Salesforce Using Apex

Webmerge is used to Customize and Automate Your Document Generation. It is an online service that self-operating your document creation process. It helps to create customized PDF and Word documents for contracts, applications, government forms, and more.


Delivery is also a walk in the part as users can choice a third party integration to send or attach documents in Salesforce or anywhere.

Why webmerge ?

As we know Document management system for Salesforce is becoming imperious to operations in an array of industries. It manages their sales lifecycle with greater ability. In terms of Salesforce, it has integrated with most of different document management system platforms for the mastery of the paperless office and the sales cycles its solution facilitates.

There is multiple document management system apps are available for Salesforce, but webmerge has some tremendous features as discussed below:


Few key points for webmerge are following :

  • Need to verify in salesforce org with key and secret to access webmerge services.
  • Logic / conditional text in templates
  • Unlimited Max templates per setup
  • External API for integrations support
  • HTML Document Builder
  • Easy Data Routing
  • Support Document generation for multiple records through Apex

Steps to process multiple records in a single request Using Apex :

One of the best things about using webmerge is this ability to process multiple records at a time using apex or javascript.

Please follow the mentioned steps to achieve this-

Step 1 – Go to the Setup -> Installed Packages -> Webmerge

Step 2 – Click on ‘View Components’

Step 3 – Search for ‘WebmergeGenerator’ Apex class and click on that.

Step 4 – Under this class search for ‘generateDocumentBatchJS’ static method and its parameter properties.

Step 5 – After taking this class and its method reference, now create an apex class whom we process multiple records at a time.

Step 6 – Go to Setup -> In Quick Find / Search type ‘Apex classes’ -> Click on ‘New’, and create a new class with following code.

//This class used to processed multiple records at a time in webmerge.

public class WebmergeBulkRecordProcessed {
public static void goRecordsToProcess(){
List <id> recordsIds = new List <id>();
for(Contact objCon : [Select Id,LastName,Email,Phone,Asst_Email__c from Contact Limit 10]){

//for only POC purpose used hardcoded id of mapping record.
} catch(Exception e){
System.debug(‘Exception type caught: ‘ + e.getTypeName()); System.debug(‘Message: ‘ + e.getMessage()); System.debug(‘Line number: ‘ + e.getLineNumber());

To find the “Mapping ID” (‘a6H0U0000004EWWUA2’), 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 “Contact”) to match your object type.

Step 7 – You may execute this class to process queryable records into webmerge by using Developer console -> Anonymous Window.


Now you analyze the all selected records are processed successfully.

Thank you!


Leave a Reply


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2020 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?