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
Step 1b: Select your Custom Object or create a new one by clicking “New Custom Object”.
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.
Step 2b: Enter the Field Set information as follows and select “Save”:
- Field Set Label: OBJECTNAME_PANDADOC
- Field Set Name: OBJECTNAME_PANDADOC
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.
Step 2c: Save the Field Set
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.
Name: CustomObjectNameJsonBuilder (Example:
Global scope and extends
Default constructor with no parameters.
You should call a parent’s constructor in your default constructor and pass 2 arguments there:
Schema.sObjectTypeof an object which you’re building
JsonBuilderfor (you can get it via
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
nulland extend later).
JsonBuilder should implement all abstract methods of a base class. If you don’t need this information, please return null.
abstract List<Recipient> getRecipients(sObject record);– returns a list of recipients from a custom object (will be prepopulated in PandaDoc);
- Items (Pricing Table Items):
abstract List<Item> getItems(sObject record);– returns a list of products (pricing table items, will be prepopulated in PandaDoc).
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:
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.
Step 5b: Enter a Visualforce Label and Name for your page.
Step 5c: Copy the source of this linked Visaulforce template and paste it into the “Visualforce Markup” section of the page settings: https://github.com/PandaDoc/pandadoc-sfdc-examples/blob/master/src/pages/CustomObjectPandaDoc.page
Step 5d: Replace the following value in the template with your controller name:
- Line 1:
Step 5e: Save the Visualforce page.
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.
Step 6b: Scroll down to “Page Layouts” and select “Edit” to edit your Custom Object’s page layout.
Step 6c: From “Fields” select “Section” and drag a new section into your page layout.
Step 6d: Be sure to name the section and select a 1-Column layout. Then select “OK”.
Step 6e: From “Visualforce Pages” select your Custom Object Visualforce Page and drag the page into the Section you just created.
Step 6f: Save the layout.
Step 7: Finished
Your Custom Object layout will now have PandaDoc documents in the view that are associated with each Custom Object record.