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 makes all decisions during the document generation and distribute 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 preselecting correct template 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 attachment, determine email recipients and then finally decide if they want to print or email the generated document(s).
With S-Docs, you can acheive 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 be generated and sent 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]|
|OPTION 1||OPTION 2||OPTION 3||OPTION 4||OPTION 5||OPTION 6|
|Default S-Docs Behavior||Preselect||“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 preselected 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.|
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 the 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:
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:
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).
Note2: 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: Preselect Templates:
This option will save user an additional click by automatically preselecting (filtering and checking off) the document to be generated. The user can still remove the preselected 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 salesforce id into a URL parameter called “doclist”. This parameter can contain multiple template ids, 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.
S-Docs Button or link URL:
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:
Note: Template IDs are salesforce generated id values associated to every record in salesforce. To retrieve the salesforce id, you will need to open the salesforce template record, and then copy/paste the id value found in the browsers address bar. The Id is the last 18 code of that url.
Note2: If you are working in a sandbox, and intend to move to production (or another sandbox) you will need to update the value of the id fields in the URL as they change between orgs.
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 determine next steps.
One-click configuration is similar URL to option 2, but should NOT contain the “onelick=false” parameter. Only the doclist parameter (which contains a comma delimited list of documents) is needed.
S-Docs Button or link URL:
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 “eye-ball” the email and make any small changes prior to sending. You can use 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 documents) 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:
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:
You can include additional email attachments to your outbound email by specifying the document id or attachment id parameters. Keep in mind, 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:
Option 6: Zero Click
This option can create documents and emails from the salesforce platform whenever a field is set to a particular value. You can therefore use workflow rules 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. Or can also do this without eve prompting the user through workflow rules!
This integration uses the S-Docs REST API, and is therefore slightly more involved to configure. An additional advantage of this method is that you can set who the document is created by (either logged in user, or any other active salesforce user). This means you can generate a document at any time as a user even when that user is not logged into salesforce. This is useful when you want to set up time based workflows that control document generation and distribution and do not need to be concerned about session ids expiring.
The complete S-Docs REST API documentation is available here: https://www.sdocs.com/documentation/s-docs-rest-api-batch-processing-workflow-automation/
Please refer to that documentation for API setup and configuration details.
The Zero-Click integration will contain APEX line that will generate the document in a similar way to option 5.
Snippet of APEX code that calls the S-Docs REST API to Auto-generate a document:
Note: Your APEX code should have fields that are used as toggles to ensure the document is NOT generated or emailed with each record update. Additionally you need to set the batch size correctly in order to avoid hitting salesforce governor limits.