S-Docs Quick Install & Configuration Guide – Lightning

Video Tutorial

Step 1: Install S-Docs

This quick installation & basic configuration guide will teach you how to install S-Docs and create & email a custom document in Salesforce Lightning Experience. To view this article for Salesforce Classic, click here.

Note: You should download and install the S-Docs package into a SANDBOX or DEVELOPER organization. We strongly advise against installing it into any production org without proper testing.

1. Navigate to our Salesforce AppExchange listing and click Get it Now.

2. You will be prompted to log into your Salesforce org.

3. Once you are logged in, you'll be given the option to install S-Docs in your production org or a sandbox instance. We highly recommend testing in a sandbox instance before installing in your production org.

4. Confirm your profile details, agree to the terms and conditions, and click Confirm and Install.

5. You'll then see the following screen. We recommend selecting Install for All Users. Click Install.

Note: Install for All Users will grant S-Docs access to the System Administrator profile and all custom profiles. You can learn more about this and the more restrictive options here.

Congratulations! S-Docs is now installed in your org.

We recommend assigning the S-Docs User or Administrator permission sets to yourself and users who will be interacting with S-Docs. Learn more about S-Docs permission sets here.

Step 2: Create The S-Docs Button

This section details setting up your S-Docs button for a standard object in Salesforce Lightning. This button will initiate the template selection and document generation processes. Although the setups are fairly similar, please reference this documentation for information regarding S-Docs in Salesforce Classic, and please refer to this documentation for more information on setting up S-Docs with a custom object.

The S-Docs button comes pre-created for the following standard objects: Contract, Opportunity, Account, Contact, Lead, Task, and Event. If you're setting up S-Docs for these objects, you only need to add the button to your page layout. However, if you plan to customize the functionality of your button with apex parameters, you should create a new button so that you can edit it in the future. For other standard objects, you will need to create a new custom button.

In this example, we will be creating the S-Docs button for the Opportunity object. From the setup menu, navigate to the Object Manager, and click the object you're creating the button for.

Click Buttons, Links, and Actions in the sidebar, then click New Button or Link.

Enter the following information for your button:
Button Label & Name: Choose a name. We'll name our button "S-Docs."
Description: Optionally enter a description, such as "Create documents for this object."
Display Type: Detail Page Button
Behavior: Display in existing window without sidebar or header
Content Source: URL
Button URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity'])}
Note: Be sure to change both instances of "Opportunity" with the name of your object in your button URL.

Note: To read about how you can customize this button to allow for one or zero click automation, click here.

Additional Note: If you encounter problems with your S-Docs button in lightning, add the lightningnav='true' parameter to your button URL. This step usually isn't necessary, but it can fix problems in lightning should they arise.

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

Add Your S-Docs Button to Your Object Page Layout

Once you save this button, you'll need to add it to the detail page layout for your object. Click Page Layouts in the sidebar of the object manager for your object. Click the arrow at the left of your page layout, then click Edit.

Click Mobile & Lightning Actions in the sidebar menu. The S-Docs button that you just created will appear in the menu of available mobile & lightning actions. Click and drag it into the "Salesforce Mobile and Lightning Experience Actions" section. Click Save when done.

Add The S-Docs Related List To Your Object Page Layout

Additionally, you should add an S-Docs Related List to your page by clicking Related Lists and dragging the S-Docs box down into the Related Lists table.

The S-Docs Related List on a given record should display all of the S-Docs ever generated for that record, as well as options to download and email those documents again. In order to display this, we need to add these columns to our Related List. Click the wrench icon on the S-Docs related list.

We recommend adding the following columns: View, Edit, Email, Doc Number, Name, Status, Doc Created On. These will display as columns from left to right on your related list (where top=left and bottom=right). To add a column, click on the column you want to add and then click the triangle button below "Add."

Additionally, we recommend sorting by Doc Created On descending.

Click OK once you’ve added all of your fields. The related list will appear as follows on a particular record’s page.

Note: Each time you edit an S-Docs template record with Auto Create Salesforce Attachment and link to record unchecked, the documents on the related list will change to reflect those edits. The related list will not store documents generated from previous versions of your templates, but rather generate a new document reflecting the most recent version of your template each time you view or email a document in this list.

Step 3: Configure Your First Template

In order to start using S-Docs, you need to configure and activate at least one template. Start by navigating to the S-Docs templates page by clicking on the App Launcher in the upper left corner, typing S-Docs into the search bar, and clicking the S-Docs app.

Click over to the S-Docs Templates tab. This page is where all of your templates will appear. To create a new template, click New.

This is the template creation page. In this example, we will create an invoice template for the Opportunity object. Each field is explained below the screenshot.

Template Name: Enter a template name. This field is required.
Description: Optionally add a description. You should include any keywords that will be useful when searching for this template, because this field and the name field are searched during the template selection step. End users will see this when they are selecting templates.
Document Category: Optionally chose a category from the picklist. Templates can be grouped together so that a user can browse templates using a category picklist. If needed, you can later customize this picklist.
Related to Type: Pick an object from the picklist. This is the base or primary object this template will use. If needed, you can customize this list with your custom objectsThis field is required.
Template Format: Pick an output format. To support the same document in multiple formats, simply clone the template with a different "Format" field value. This field is required.
Document Version: Optionally use this field to track any internally used version number (or date) for this template. This is only for reference purposes.
Available for Use: Keep this box checked (it is checked by default). This ensures that the template is visible for document creation.
Initially Visible: Keeping this box checked (it is checked by default) will make this template visible on initial load of the document creation page based on the object type. Typically, you want to set this checkbox for the 10 most used templates for each object type.
Allow Edit: If you want users to be able to edit this document after it has been generated, check this box. Learn more about this feature.

Once you've filled in all of the values to your specifications, click Save. The template is now ready to be edited.

Utilize the Template Editor

Click the arrow on the left of the template detail page to show more buttons, then click the Template Editor button to design your template.

This is a very basic overview of the template editor. For a more in-depth explanation, click here.

This is the WYSIWYG template editor (What You See Is What You Get). Add some text, place the cursor where you want your Salesforce record data to be merged into the template, and then click on the Insert field button.

Select the field from the object you want to insert and click Insert.  The editor will add the merge field in the correct syntax into the template editor.

Repeat the above step for other fields.  In addition, you can add related lists and insert conditional logic. You can also use the editor tools to modify the document formatting. Or, click Source to view the HTML and add your own styles; the customization options are endless! Click Save when done.

You have now created your first template!

Note: You can also insert images, span related objects and create child object line items and add CSS stylesheets. Click here for an in-depth explanation of the template editor, or click here to read about advanced template editor features.

Step 4: Generate And Email Your First Document

Open any record for your object and click the S-Docs button you just created.

The template you created earlier will appear. (If it doesn't, make sure you’ve checked the Available for Use and the Initially Visible checkboxes when you created your template. Additionally, make sure you set "Related to Type" to the object you're using.) Select the template and click Next Step.

The document will generate in seconds. You can click on the "View" icon or the document number to view or download your document, or click the pencil icon to edit your document (this option is only available if Allow Edit has been checked on the template record). Click Email Selected Docs to bring up the email page for emailing the document.

You can edit all of the normal email fields on the email page, as well as the body of the email itself. The document you just generated is automatically added as an attachment to the email. To learn more about how to create custom email templates that automatically fill these fields in for you, click here.

Click Send when done. You have now created and emailed your first document with S-Docs!

Email Failure Troubleshooting

By default, S-Docs links outbound emails to the contact record with a matching email address; Salesforce requires this linkage. If you try to send an email to an email address that is not listed under any Contact record in your org, S-Docs will attempt to link it to a single dummy contact record called "No Contact Record." This contact record is created automatically by the S-Docs package to handle this linkage, and is immediately deleted once the email is sent.

If your org has implemented validation rules that require additional contact fields to be completed, then the S-Docs package will not be able to create this contact record. In this case, there are two main options.

Option 1 (Recommended)

Create a before insert, before update Apex trigger on the Contact object that automatically changes the fields on the No Contact Record that S-Docs creates so that your validation rules are not triggered. For example, the trigger might look like this if your validation rules prevent the contact field "This_Cannot_Be_Null__c" from being null:

trigger ContactFirstName on Contact (before insert, before update) {
    for (Contact c : trigger.new) {
        if (c.LastName == 'No Contact Record') {
            c.This_Cannot_Be_Null__c = 'some non-null value';
        }
    }
}

With this option, S-Docs will be able to create and delete the No Contact Record, and the email will be sent and logged in Activity History on the base object record.If you require test coverage for your No Contact trigger, you can use the following test class:

Class Name: NoContactTestClass

@isTest
private class NoContactTestClass {    @isTest
    public static void noContactTest() {
      Test.startTest();
        Contact testContact = new Contact();
        testContact.LastName = 'No Contact Record';
        insert testContact;
        Test.stopTest();
    }}

Option 2Create the S-Docs No Contact Record manually with all of the fields filled in that are required by your validation rules. The fields that S-Docs requires should be filled in as follows:
First Name: Not Required. We recommend writing S-Docs to avoid confusion.
Last Name: No Contact Record
Email Address: this.email@is.invalid

You then need to add the following parameter to the end of your S-Docs button: useExistingNoContactRecord='true'

Example:

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

Note: This option is not recommended, as the email will not be logged in Activity History on the base object record.

Sandbox Deliverability

If you are testing S-Docs in a sandbox org and emails are not being delivered, you should check Setup > Email Administration > Deliverability, and check that "Access to Send Email" is set to "All email." By default, Salesforce turns off outbound email access when a sandbox is created to reduce the risk of inadvertently sending emails to contacts during development and testing. Be aware that this change affects the entire sandbox and not just S-Docs.

Tags: , , , ,

Was this helpful?