Automation Options: Improving Efficiency and Compliance

Feature Overview

S-Docs is a powerful tool that allows you to generate and email documents natively on the Salesforce platform. By default, the user experience is very flexible. However, this flexibility means that the user makes all decisions during the document generation and distribution process, which takes time. As an administrator, you may want to automate the process to gain efficiency (to reduce time and clicks), reduce errors (by pre-selecting correct templates based on data) and to ensure compliance (to enforce business rules). S-Docs provides a one-click and zero-click feature described in this document to ensure you can tailor the user experience to meet your business requirements.

The document automation process can be considered a spectrum from maximum flexibility to maximum automation. The out-of-box behavior of S-Docs provides maximum user flexibility. In this use case, the user chooses the document(s), along with the default email template. They decide whether to include additional attachments, determine email recipients, and then finally decide if they want to print or email the generated document(s).

With S-Docs, you can achieve complete automation – meaning an event or field change could drive a fully automated document generation and distribution process, even when the user is not logged into Salesforce! For example, an account status changed to “closed” could generate a win-back email and special offer without any user involvement. Or, a case status change to “Ready for Proposal” could generate a proposal and send it to the client. You can see that there is a huge opportunity to improve your business process. As an administrator, you determine what level of automation is appropriate for your organization to meet your requirements. This document explains how S-Docs can be used to achieve those results.

S-Docs Automation Spectrum

Maximum Flexibility [Most clicks]                                                          Maximum Automation [Least clicks]
Default S-Docs Behavior Pre-select “One Click” One-Click + Email Prep One-Click + Email Send “Zero-Click”
User chooses every aspect of doc generation, attachments, and email options. You can add filter rules to help selection process. Saves one step to filtering by selecting the default document(s) based on data such as language or product type. User can override pre-selected  docs as needed. Documents along with email cover letter are generated with a single click. User can then choose to print, return to record or proceed to email. One-click leads to fully populated email page with all attachments, default email message and recipients completed. User can verify email and make edits as needed before sending. One-click, document(s) are generated and emailed. Screen returns to the record detail page without any further user input. User cannot change document or messaging. A Field change, or workflow sets off a trigger that generates and optionally emails the document(s). This is fully automated and ideal for mobile devices.


The following options provide you with edits to the S-Docs button that you can use to increase automation. To get to the button edit page, navigate to the Setup menu and click Object Manager. Click the name of your object.

Then, navigate to the Buttons, Links, and Actions tab. Find the S-Docs button, click the arrow on the right, and click Edit.

Note: The S-Docs button comes prepackaged for the following standard objects: Contract, Opportunity, Account, Contact, Lead, Task, and Event. Because of this, the button will be managed and therefore unable to be edited for these objects. You will need to create a new S-Docs button (and replace the old button on the object's page layout) to make edits.

Option 1: Default Behavior & Adding Template Filters

S-Docs default behavior allows a user to choose any document(s) to generate along with any email template. The user can then decide to print or email the document. If emailed, the user can attach additional files, add recipients and customize the email message before it is sent. While this provides for maximum flexibility, it also requires the greatest amount of user interaction (clicks).

You can reduce template searching by optionally providing an initial search filter to the template list. When the user clicks on the S-Docs button, a subset of templates can be displayed to help them find the most likely one needed. This is done by using a search filter and/or category filter, as in the button URL. But keep in mind, the Salesforce user will still need to click the checkbox next to the template and then click the “Next" button to continue. If you want the box checked for them, you need to move to Option 2. Option 1 is useful when you have many templates and want to simply help the user by providing the likely choice. Users can still search for and use other templates as needed.

The first example below shows the button syntax where the templates are initially filtered based on a dynamic field value such as the language preference of the client. Using the “searchfilter” parameter below will automatically display only templates that have a “Name” or “Description” field that contains the value of the searchfilter parameter.

Button or Link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity',

Similarly, you can filter based on the value of the template’s “category” field. In this example, only templates with a category of “Contract” will be displayed by default. Button or Link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity',
Note:You can use both searchfilter and categoryfilter parameters together within the same button. When doing so, both conditions need to be met for the related templates to appear (i.e. they are joined by an “AND” condition).
Note 2:
 If you want to restrict access to templates based on user or profile, you can easily implement this using Salesforce’s sharing model feature. You would need to change the SDTemplate object to a private sharing model and then configure your sharing rules based on your business requirements.

Option 2: Pre-select Templates:

This option will save users an additional click by automatically pre-selecting (filtering and checking off) the document to be generated. The user can still remove the pre-selected template and choose their own if they wish to override the default selection. The user will then need to click on the Next Step button to generate the document. This option is useful when you have business rules that can identify the correct template in the majority of use cases, but still allows the user to override the default selection if needed.

This automation is achieved by passing the template’s name into a URL parameter called “doclist.” This parameter can contain multiple template names, but they must be separated by a comma. Additionally, the oneclick parameter needs to be set to false. This tells the S-Docs engine to stop for further input. Note that if there are multiple templates with the same name in your org, all of them will generate if one of them is referenced by this parameter.

Note: You can also use template IDs for the doclist parameter, however this is not recommended because these IDs will change between sandbox and production orgs, meaning that you will have to re-add the new template IDs into this parameter after transferring to production.

S-Docs Button or link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity',

The doclist parameter can also be dynamically set using Salesforce functions within the button like “IF” or “CASE.” This button will choose the correct document and email template based on a field value. S-Docs Button or link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Contact.Id, Object='Contact',
doclist=IF(Contact.Department=='Finance', 'Finance_Template', 'All_Other_Depts_Template')])}

Option 3: One-Click Generation

The “one-click” builds on Option 2 but takes it one step further – the document(s) are generated without the user selecting any templates. Once the user clicks the S-Docs button, they will go directly to the list of newly generated documents. From there, they can then decide to view, print, email or return to the original Salesforce record. This option achieves one-click generation while still allowing the user to determine next steps.

One-click configuration is a similar URL to option 2, but should NOT contain the “oneclick='false'” parameter. Only the doclist parameter (which contains a comma delimited list of documents) is needed.

S-Docs Button or link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity',

Option 4: One-Click + Email Prep

The “one-click” builds on Option 3 but again goes one step further – by pushing the user and documents to an email screen. To effectively use this option, one of the templates in the doclist should be of type “HTML.” This HTML template will comprise the default email body and can set the default subject line and recipients for the outbound email being prepared.

Any other S-Docs templates that are included in the doclist will be automatically added as attachments. This option is appropriate where you want to give the user the opportunity to “eyeball” the email and make any small changes prior to sending. You can leverage the advanced features of the S-Docs Template to default all email values and lock down fields where you want to restrict the users. One-click is configured with a “prepemail='1'” parameter in the S-Docs button URL. Only the doclist parameter (which contains a comma delimited list of template names) and prepemail parameters are needed. Again, when using this feature, one of the templates in the doclist should have an output type of “HTML” that will set the default email body. S-Docs Button or link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity',

Option 5: One-Click + Email Send

This option will create the document and email it according to the parameters in the button and the configuration of the S-Docs templates included in the doclist parameter. This MUST contain an HTML template as one of the doclist parameters, and that template MUST contain at least a default “To” address, subject line and email body. Without this set, it will not be a valid email. The users will return to the original record detail page once complete. This is a useful option when you want complete control of the messaging but still allow the user to control when the message is generated.

S-Docs Button or link URL:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity',

You can include additional email attachments to your outbound email by specifying the document ID or attachment ID parameters. Keep in mind that these records need to exist within Salesforce prior to the document generation process so their IDs can be included in the URL. Attachments use the parameter “aid=”  followed by a comma delimited list of Salesforce IDs corresponding to attachment records. Salesforce documents use the parameter “did=” and the list of Salesforce IDs for the document record. S-Docs Button or link URL with additional attachments from attachment related list and documents tab:

{!URLFOR('/apex/SDOC__SDCreate1', null,[id=Opportunity.Id, Object='Opportunity'

Option 6: Zero Click

Please note that zero-click automation is only available to S-Docs Unlimited Edition customers for an additional fee.Click here to contact our team for more information.

This option can create documents and emails from the Salesforce platform whenever a field is set to a particular value. You can therefore use Salesforce Flows or apex triggers to update a field value, which in turn can generate and optionally email documents through S-Docs. This option is ideal for behind-the-scenes document generation and distribution. It is also ideal for mobile devices, since it is a field change that runs a process without further user interaction. For example, you can easily add a custom picklist field on a mobile page layout. The user simply changes the value and saves the record. All document processing is handled post-save on the Salesforce platform. You can also do this without even prompting the user!

This integration uses the S-Docs Jobs Object in conjunction with the Salesforce Flows, apex triggers, and other batch generation methods. You can learn how to use S-Docs Jobs for zero-click automation by reading this documentation.

Tags: , , , ,

Was this helpful?