Salesforce Integration with PandaDoc – Part 1a: Adding PandaDoc module to Custom Objects in Salesforce

Focus: The focus of this document is to provide you steps on how to install the PandaDoc module into custom objects in Salesforce.

If you have not gone through the installation of PandaDoc into Salesforce, please click here and follow all steps.

If you created a “Custom Object” in Salesforce and you want to add the PandaDoc module to it, you will need go through the steps for each Custom Object. (Click here to learn how to create a Custom Object within Salesforce)

Salesforce Versions for Custom Objects: You will need Salesforce: “Enterprise”, “Unlimited”, or “Developer edition”. Salesforce Pro does not offer access to APEX classes and are unable to use custom objects with this integration.

For developers, click here to find detailed documentation with code examples on how to add custom objects to your Salesforce-PandaDoc integration.

Step 1: Create or Access Your Salesforce Custom Object

Step 1a: Go to Setup -> Build -> Create -> Objects

SFDC - Custom Objectss -1 SFDC - Custom Objectss -2

Step 1b: Select your Custom Object or create a new one by clicking “New Custom Object”.

SFDC - Custom Objectss -3

Step 2: Create a Fieldset for the Custom Object

Step 2a: Scroll down to the section “Field Sets” and select “New” to create a new Field Set for the Custom Object.

SFDC - Custom Objectss -4

Step 2b: Enter the Field Set information as follows and select “Save”:


For this example, we’ll create a Custom Object called “Service City”, representing an area a business provides services in. We might have documents to store for operations in each area.

SFDC - Custom Objectss -5

Step 2c: Save the Field Set

SFDC - Custom Objectss -6

Step 3: Create Custom JSON Builder for Custom Object

PandaDoc will look for a custom JSON builder for your custom object to serialize the Custom Object’s data and pass it to PandaDoc when you create a document from your Custom Object’s page.

Step 3a: From the Salesforce Developer Console or your own IDE software, create a new Apex Class with the following parameters.

SFDC - Custom Objectss -7 SFDC - Custom Objectss -8

Name: CustomObjectNameJsonBuilder (Example: ServiceCityJsonBuilder)

SFDC - Custom Objectss -9

Global scope and extends pandadoc.JsonBuilder

SFDC - Custom Objectss -10

Default constructor with no parameters.

SFDC - Custom Objectss -11

You should call a parent’s constructor in your default constructor and pass 2 arguments there:

  • Schema.sObjectType of an object which you’re building JsonBuilder for (you can get it via [sObjectName].getSobjectType())
  • Map<String, Set<String>> – a Map where you define nested objects you want to add to JSON. Key is a name of child relation and value is a list of fields from child relation object. You can pass null, if you don’t need to configure child relations. (Start with null and extend later).
SFDC - Custom Objectss -12

JsonBuilder should implement all abstract methods of a base class. If you don’t need this information, please return null.

  • Recipients: global abstract List<Recipient> getRecipients(sObject record); – returns a list of recipients from a custom object (will be prepopulated in PandaDoc);
  • Items (Pricing Table Items): global abstract List<Item> getItems(sObject record); – returns a list of products (pricing table items, will be prepopulated in PandaDoc).
SFDC - Custom Objectss -13

Leaving Recipients and Items as null will work to get started. However if you wish to provide Recipients or Items, here is the format hard coded as Strings:

SFDC - Custom Objectss -14

Step 4: Add the created JsonBuilder Class to a Json Builder Factory

Step 4a: Go to Pandadoc Setup, scroll down to JSON builders settings, click “Add JSON builder”

Here you must add the JSON builder class name you just created and custom object name (API name) where you want to add the PandaDoc module.


Step 5: Create a VisualForce Page for the Custom Object

To embed the PandaDoc module your custom object pages, you will need to create a VisualForce component and add it to custom object’s page layout.

Step 5a: Go to Setup -> Develop -> Visualforce Pages and click on “New” to add a new Visualforce page.

SFDC - Custom Objectss -19

Step 5b: Enter a Visualforce Label and Name for your page.

SFDC - Custom Objectss -20

Step 5c: Copy the source of this linked Visaulforce template and paste it into the “Visualforce Markup” section of the page settings:

Step 5d: Replace the following value in the template with your controller name:

  • Line 1: StandardController="PD_Custom_Object__c"

Step 5e: Save the Visualforce page.

SFDC - Custom Objectss -22

Step 6: Insert the Visualforce page into your Custom Object view.

Step 6a: Go to Setup -> Create -> Custom Objects, and select your Custom Object from the list of Custom Objects.

SFDC - Custom Objectss -2

Step 6b: Scroll down to “Page Layouts” and select “Edit” to edit your Custom Object’s page layout.

SFDC - Custom Objectss -23

Step 6c: From “Fields” select “Section” and drag a new section into your page layout.

SFDC - Custom Objectss -24

Step 6d: Be sure to name the section and select a 1-Column layout. Then select “OK”.

SFDC - Custom Objectss -25

Step 6e: From “Visualforce Pages” select your Custom Object Visualforce Page and drag the page into the Section you just created.

SFDC - Custom Objectss -26

Step 6f: Save the layout.

SFDC - Custom Objectss -27

Step 7: Finished

Your Custom Object layout will now have PandaDoc documents in the view that are associated with each Custom Object record.

SFDC - Custom Objectss -28

Have questions? For faster support please:

  1. Log in to PandaDoc
  2. Click on the “Help” button next to your profile icon
  3. Choose Submit Help Request option

Or feel free to contact us using our public form:

Contact Support