Configure S-Docs With Custom Objects – Salesforce Lightning


S-Docs works great with the custom objects and even the platform edition, which is entirely comprised of custom objects. Your documents can span many relationships to include data from formula fields, rich text, parent records, child, grandchild and related objects--all within the same document.

Since every organization creates different custom objects to meet their unique requirements, you need to configure S-Docs to recognize which custom objects you want to leverage with S-Docs.

To learn how to configure S-Docs with custom objects in Salesforce Lightning Experience, you can watch the following tutorial video, which will walk you through the process. You can also refer to the written instructions below the video, which provide a detailed, step-by-step guide to configuring S-Docs with custom objects. To view the same guide for Salesforce Classic, click here.

For the purposes of this guide, we assume your custom object is named CustomObj and has an API name of CustomObj__c. (Note: the API name has two underscores.) Whenever you see "CustomObj" in this document, you can replace it with the name of your custom object. S-Docs can also integrate with other AppExchange apps. (Note: there are a few setup differences.) This document will walk you through the step-by-step configuration process in Salesforce Lightning. It is intended for administrators who are familiar with standard configuration tasks.

Sample templates can be found here.

Tutorial Video

Step 1: Add a lookup field to allow relationship linking [00:54]

This step allows you to associate the S-Doc with the Custom object, so that users can see a related list of all S-Docs created on your Custom Object's page layout.

  1. In the Setup menu (the gear in the upper right corner), navigate to the object manager and select SDoc Relationship.
  2. Click Fields & Relationships in the sidebar, then click New.
  3. Follow the New Custom Field steps:

Step 1 of 6 - Pick Lookup Relationship. Click Next.
Step 2 of 6 - Select your Custom Object (e.g. CustomObj__c) from picklist values, then click Next.Step 3 of 6* - Field label and field name should be your custom object name without the “__c.”  In our example it would be "CustomObj." Click Next.

*Note: If you are using S-Docs with another AppExchange managed package, your field name in step 3 above will need to accommodate for the double underscore in the field name, which is not allowed by Salesforce. Since your API name includes the domain name of the package followed by two underscores and then the object name (e.g. package__CustomObj__c), you will need to replace the first double underscore with “_u_” and remove the remaining “__c.” In our example, your field name should be set to: package_u_CustomObj.

Step 4 of 6 - Checkbox should be visible for all users. Click Next.

Step 5 of 6 - Checkbox should add the field for the layout.

Step 6 of 6 - Accept default. Click Save.

Step 2: Create a button to place it on your Custom Object page Layout [02:06]

Just like using S-Docs with other objects, you need to place an S-Docs button on the record detail page layout. Users will click the button to initiate creating a document from the record detail page.

Create the S-Docs button

  1. Navigate back to the Object Manager in the Setup menu and click on the name of your custom object.
  2. Click Buttons, Links, and Actions in the sidebar and click New Button or Link.
  3. Button Label: Choose a label (e.g. "S-Docs")
  4. Display Type: Detail Page Button
  5. Behavior: Display in existing window without sidebar or header
  6. Content Source: URL
  7. Use the following URL (note that double underscores are used in three places):
    {!URLFOR('/apex/SDOC__SDCreate1', null,[id=CustomObj__c.Id, Object='CustomObj__c'])}

Note: If you are using S-Docs with an object within another AppExchange managed package, your button syntax should include the entire object API name that includes the domain (e.g. package__CustomObj__c). Note that double underscores are used throughout. Your button syntax should therefore look similar to the following:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Package__CustomObj__c.Id, Object='Package__CustomObj__c'])}

  1. *Optional* You can have users save clicks by enabling the “One-Click” feature. Enabling this will bypass the document creation wizard. An administrator simply needs to change the button definition to include a list of pre-selected S-Docs template names that will be automatically generated. Placing this button will let users create all the documents encoded in the button without any additional interaction. The button syntax uses a parameter called “doclist,” which is followed by one or more template names to be auto-generated. Here is an example of the button syntax (replace the highlighted values with your own template names):
    {!URLFOR('/apex/SDOC__SDCreate1', null,[id=CustomObj__c.Id, Object='CustomObj__c', doclist='Template1,Template2'])}
  2. Click Save

Step 2b: Place button on your page layout [02:52]

  1. Navigate back to the Object Manager in the Setup menu and click the name of your custom object.
  2. Click on Page Layouts in the sidebar, then click the Edit link (you will repeat this for each page layout that you want the S-Docs button to appear in).                                         
  3. In the layout editor, scroll down to the “Salesforce Mobile and Lightning Experience Actions” section and click override the predefined actions.
  4. Then, click Mobile & Lightning Actions in the top menu. Find the S-Docs button you just created, and drag it down into the “Salesforce Mobile and Lightning Experience Actions” section. 
  5. Be sure to click Save to apply the changes to the page layout and repeat steps 3-6 for any other layouts where you would like to add the button.

To use this new S-Docs button, you first need to add your custom object as an available picklist value in the "Related to Type" field on the S-Docs template detail page, and then create at least one template to use with your custom object. The next two steps describe this process.

Step 3: Add Your Custom Object API Name  to the "Related to type" field on the "SDoc Template" object [03:25]

  1. Navigate back to the Object Manager, then click on the S-Doc Template link. 
  2. Click on Fields & Relationships in the sidebar, then click on the Related to Type link.
  3. Scroll down to the "Values" section and click on the New button.
  4. Add your custom object’s API name (e.g. CustomObj__c)  as a picklist value, then click Save.
Note: if you are using S-Docs with another AppExchange managed package, then your custom object API name should include the domain name of the package followed by two underscores and then the object name (e.g. package__CustomObj__c). You should use the entire API name for the S-Docs picklist value.

As a reminder, you should substitute your object’s API name (not use the example CustomObj__c shown above).

Step 4: Create your Custom Object Template [04:09]

  1. Go to the S-Docs template home page by clicking on the App Launcher in the upper left corner and selecting S-Docs.
  2. Navigate to the S-Docs Templates tab and click New.
  3. Create your Custom Object template record. Be sure to select your Custom Object name from the “related to type” picklist values. Before you can first use this template, you should confirm you have also checked the Available for Use and Initially Visible checkboxes. 
  4. Click Save, then click the Template Editor button. 
  5. Once in the editor mode, you can design your template using the WYSIWYG editor. The editor allows you to add text, format styles, insert tables, insert images and merge Salesforce data by using the Insert Field and Insert Related List buttons.
  6. You can also edit the template HTML directly by clicking on the Source button. You can additionally paste pre-made template code here. Sample templates are available here.
  7. Once your template is saved, you can test it by opening a sample custom object record, clicking on the S-Docs button, selecting your new template, then clicking on Next Step
  8. Click on the View PDF icon or the document number to view or download the document.
  9. The document will open in another tab with all of the fields filled in.

Tags: , ,

Was this helpful?