Add Support for Salesforce and Custom Objects

After you’ve logged into Formstack Documents, click the Formstack Settings tab.




Here you can add or remove support for various Salesforce objects.  These are the primary objects that you want to be able to merge data from.  Feel free to add any of your standard or custom objects.

Note: When adding a custom object, you may have to enter the Salesforce Object API Name and select the Save button in order to add it to your list under the settings page. 

Adding Merge Buttons for other Salesforce Objects

Formstack Documents for Salesforce works with a few standard Salesforce Objects out of the box. If you’d like to add more, you can do so.

    • Go to Setup 
    • Type Visualforce Pages in the Quick Search 
    • Click the New button
    • Add your page code. Set the standardController property on the page to be the object you’d like to add support for. Also, add the docType and optionally add your own title. In the following example, we are displaying the certificate name. Keep in mind that not every Salesforce object has a Name property.
      <apex:page standardController="Certificate__c" docType="html-5.0" title="Webmerge Certificate: {!Certificate__c.Name}">
          <webm:WebmergeWizard record="{!Certificate__c}" />
    • *Note: if you are receiving Apex errors about missing columns, please check your Version Settings and go back a few versions for your Salesforce API version (try version 29.0 first).

    • *Optional:  If you would like to auto-select a mapping, you can add a "mappingId" parameter to your VF page code to send the Mapping ID to the VF page: <webm:WebmergeWizard record="{!Certificate__c}" mappingId="0x0000002384dbna" />

    • *Optional: If your object doesn't have a "Name" field, you will need to add a "nameField" parameter to your page code to tell the system what field to use instead of Name.  Like this: <webm:WebmergeWizard record="{!Certificate__c}" nameField="Certificate_Id__c" />

    • *Optional: If you would like files to be previewed in the browser instead of a download, use browserPreview="true".  Like this: <webm:WebmergeWizard record="{!Certificate__c}" browserPreview="true" />

    • *Optional: If you would like the merge window to automatically close after merging, use autoClose="true".  Like this: <webm:WebmergeWizard record="{!Certificate__c}" autoClose="true" /> *Please note, this option is currently only available in Classic*

    • Security: Once you create the VF page, you'll need to give permissions to the User Profiles that you want to have access to this page. Under the main Visualforce Pages, click the Security link next to your page.

  • Create a new button: Set the button type to Visualforce and select your new Visualforce page.
    • Go to Setup 
    • Type Object Manager in the Quick Search 
    • Click on the object you want to create the button for
    • Under the Buttons, Links, and Actions section, click New Button or Link
    • Give the button a name and choose the Content Source to be VisualForce Page, then choose the page you just created

  • Add your new button to a Page Layout
    • Go to the Detail page for your object, and click the Edit Layout link
    • Choose Buttons from the left side and then drag your newly created button onto your layout, and save.


If you want the action button to be visible in a Lightning Experience or Mobile page, there's a couple of extra steps:

  • Click Mobile & Lightning Actions
  • Click and drag the button to the Salesforce Mobile and Lightning Experience Actions section and arrange it as necessary


Adding Apex Triggers for other Salesforce Objects

You only need to take this step if you need plan on automatically generating documents when a record is inserted/updated. If you are just clicking the buttons, you don't need to worry about the triggers.

**Note: You can now use the Process Builder to automatically generate documents. You do not need to use this functionality anymore. See:

  • Install Formstack Documents: If you have not installed the Formstack Documents Managed Package in your sandbox, please do that first.

  • Create a new Apex Trigger: Select the Salesforce Object you’d like to trigger on and select After Insert and After Update only. Do not set any other values for this.

  • Add the Apex Trigger code: Add the following code snippet to your new Apex Trigger.

    trigger TriggerName on ObjectName (after insert, after update) { new
        webm.WebmergeTriggerEvaluator(, Trigger.old).doTrigger(); 

    For the Invoice object, the trigger would look like this:

    trigger MyInvoiceTrigger on Invoice__c (after insert, after update) { 
        new webm.WebmergeTriggerEvaluator(, Trigger.old).doTrigger(); 
  • Setup Test Class: Salesforce requires you to have test classes for code coverage, so we'll need to add a test class under Setup > Develop > Apex Classes. Copy and paste the code below into your new class file, then update the object name to match your object (ie in our example we're using Invoice__c)

    private with sharing class TriggerTests
        static testMethod void invoiceTests()
            List<webm__Webmerge_Mapping__c> mappings = [Select Id from webm__Webmerge_Mapping__c LIMIT 1000];
            delete mappings;
        webm__Webmerge_Mapping__c mapping0        = new webm__Webmerge_Mapping__c();
        webm__Webmerge_Mapping__c mapping1        = new webm__Webmerge_Mapping__c();
        Invoice__c          obj         = new Invoice__c();
        obj.Name                    = 'Bob';
        mapping0.webm__Active__c              = true;
        mapping0.webm__Evaluation_Criteria__c         = 'created, and every time it\'s edited';   
        mapping0.webm__Salesforce_Object_Name__c      = 'Invoice__c';
        mapping0.webm__Autogenerate__c            = true;
        mapping1.webm__Active__c              = true;
        mapping1.webm__Evaluation_Criteria__c         = 'created, and any time it\'s edited to subsequently meet criteria';
        mapping1.webm__Salesforce_Object_Name__c      = 'Invoice__c';
        mapping1.webm__Autogenerate__c            = true;
        insert new List<webm__Webmerge_Mapping__c> {mapping0, mapping1};
        webm__Field_Mapping__c fieldMap0      = new webm__Field_Mapping__c();
        fieldMap0.webm__Webmerge_Field_Id__c      = '1233';
        fieldMap0.webm__Webmerge_Field_Name__c    = 'CompanyName';
        fieldMap0.webm__Salesforce_Field_Name__c  = 'Name';
        fieldMap0.webm__Salesforce_Field_Id__c    = 'Name';
        fieldMap0.webm__Webmerge_Mapping__c       = mapping0.Id;
        webm__Field_Mapping__c fieldMap1      = new webm__Field_Mapping__c();
        fieldMap1.webm__Webmerge_Field_Id__c      = '1233';
        fieldMap1.webm__Webmerge_Field_Name__c    = 'CompanyName';
        fieldMap1.webm__Salesforce_Field_Name__c  = 'Name';
        fieldMap1.webm__Salesforce_Field_Id__c    = 'Name';
        fieldMap1.webm__Webmerge_Mapping__c       = mapping1.Id;
        insert new List<webm__Field_Mapping__c> {fieldMap0, fieldMap1};
        webm__Webmerge_Mapping_Criteria__c    crit0 = new webm__Webmerge_Mapping_Criteria__c();
        webm__Webmerge_Mapping_Criteria__c    crit1 = new webm__Webmerge_Mapping_Criteria__c();
        crit0.webm__Field__c          = 'Name';
        crit0.webm__Operator__c       = 'equals';
        crit0.webm__Value__c          = 'Steve';
        crit0.webm__Webmerge_Mapping__c   = mapping0.Id;
        crit1.webm__Field__c          = 'Name';
        crit1.webm__Operator__c       = 'equals';
        crit1.webm__Value__c          = 'Bob';
        crit1.webm__Webmerge_Mapping__c   = mapping1.Id;
        insert new List<webm__Webmerge_Mapping_Criteria__c>{crit0, crit1};
        insert obj;
        obj = [SELECT Id, Name FROM Invoice__c WHERE Id = :obj.Id LIMIT 1];
        obj.Name = 'Steve';
        update obj;
Was this article helpful?
4 out of 5 found this helpful


  • I want to add the merge information(attachment information) to the Custom Object after the merge.
    How to do i get the information in the triggers ?

    Thanks in advance

  • Hi Saraswathi,

    That setting is actually handled in your WebMerge Mapping. Please click the "Save in Attachments" option under Optional Settings.


  • Trying to add for Events but the VF kicks back the error

    "Invalid field Name for SObject Event
    Error is in expression '{!obj[nameCol]}' in component in component webm:webmergewizard
    Error evaluating dynamic reference 'Name'"

    Afraid I have zero experience with VF and APEX, but you mention that "Keep in mind that not every Salesforce object has a Name property."

    Does this mean I can't use this product on Event object/objects with no Name property?



  • Hi Matt,

    You can still use it! You just need to define the nameField parameter in the VF page code like this:

    We then use the field name you use inside the "nameField" property. Can you try that for me?

  • Hi Jeremy,

    Thanks for your response, but your example didn't paste?

    Am I right in thinking it would be something like "{!event[subject]}", since events don't have name fields...?



  • Matt,

    Sorry, I'll paste an example without the open and closing arrows on the tags:

    webm:WebmergeWizard record="{!Certificate__c}" nameField="Certificate_Title__c"

  • Hi Jeremy,

    That's working now, thanks! I glossed over the optional sections where this was outlined, as I was trying to get the basics off the ground before looking at options. Lesson learned: Read the manual! :-)

    All the best,


  • Hello Jeremy.
    I have enabled "Allow users to Preview document" in the mapping, however users still cannot see the preview button. As an admin I can see the preview button. Is there any setting I am missing to show the preview button to users?

  • Hi Rohit,

    That's very strange - that button isn't based off user permissions so I'm not sure what could be hiding it. Can you please create a support ticket so our team can help you investigate?

  • Thank you Jeremy, created support ticket as suggested.

  • Hi Jeremy, getting the following error message "Contribution__c is not enabled for feeds; An unexpected error has occurred. Your solution provider has been notified. (ConnectApi) "

    As you have guessed Contribution__c is the custom object on which I added the webmerge button.

  • Hi Pierre,

    I "think" that's an error with Salesforce Chatter not being activated on that custom object. Can you look into that for me?

  • You were right Jeremy, I submitted a request with another issue if you don't mind having a look. Thanks!


Please sign in to leave a comment.