Category

Best Practices

Sandbox Refresh Considerations

By Best Practices, Documentation, S-Docs Cookbook No Comments

migrate
migration
import
upload
transfer

Introduction

When you refresh a sandbox org that you are using with S-Docs, there are a few considerations to keep in mind to ensure you can continue using S-Docs like normal once the refresh is complete. This article will detail what actions to take when you refresh your sandbox from production.

You may also want to view Salesforce's Sandbox Considerations article for additional tips on what to do when refreshing your sandbox org.

Note: You do not need to reinstall S-Docs or S-Sign when you refresh your sandbox.

Record IDs

Although sandbox record data will be identical to production record data after a sandbox refresh, sandbox and production record IDs are always unique between different orgs. S-Docs can be affected by this in two main ways.

Template Preview IDs

If you're using the template editor Save & Preview feature, record IDs in the Preview ID field will point to production records after a sandbox refresh. You must replace these IDs with corresponding sandbox record IDs. Record IDs can be found in your browser's URL bar when you're viewing a record.

The Preview ID field can be found in the template editor under the Advanced Options tab.

S-Docs Template IDs 

If you've referenced S-Docs template IDs anywhere in your org, they will point to production template records after a sandbox refresh. You should replace these references with plain text template names. You can also replace them with sandbox template IDs, but we recommend using the template name since record names don't change between production and sandbox orgs. This way, you won't have to update these references after future sandbox refreshes, or when you migrate templates from sandbox to production orgs.

S-Docs template IDs are commonly referenced using the doclist parameter with document automation with S-Docs Jobs, mass merge, or one-click/zero-click S-Docs buttons.

URLs

Any references to login.salesforce.com must be changed to test.salesforce.com, and any references to your Salesforce production domain (e.g. na132.salesforce.com) must be changed to your Salesforce sandbox domain (e.g. cs5.salesforce.com). S-Docs can be affected by these URLs in the following places.

Custom Settings

From the setup menu, type "Custom Settings" into the Quick Find bar and click Custom Settings in the dropdown menu. Find the SDocsSettings entry and click Manage.

Click the Edit link next to SDocsSettings.

Then, ensure that any references to the Salesforce production login URL or your Salesforce production domain are updated. In the following example, #1 would need to be updated to test.salesforce.com, and #2 would need to be updated to a sandbox domain, such as cs5.salesforce.com.

You may also need to update the ConnectedAppUserName if you are using the Run As User feature. This username is used as the "run as" user if the provided username is not found or not valid. It must be a valid Salesforce username in your sandbox org, and the user must be active.

Remote Site Settings

If you have a remote site setting configured for the Salesforce production login URL or your Salesforce production domain, you'll need to add new remote sites for your Salesforce sandbox login URL and your Salesforce sandbox domain.

From the setup menu, type "Remote Site" into the Quick Find bar, click Remote Site Settings in the dropdown menu, and click New Remote Site to add your sandbox remote sites.

Run As User Connected App

If you're using the Run As User feature, you'll need to update your Connected App's Callback URL. From the Setup menu, type "Apps" into the Quick Find bar, then click App Manager in the dropdown menu. Find the SDocs Connected Apps entry, click the dropdown arrow, and click Edit.

Scroll down to the API (Enable OAuth Settings) section, and update the Callback URL to:

https://test.salesforce.com/services/oauth2/callback

Click Save.

S-Sign Considerations

After refreshing a sandbox from production, your S-Sign Site will be updated to your production site. The production site URL includes your Salesforce production domain, which will not function properly in your sandbox and cannot be edited.

Because of this, you must deactivate the production site and create a new site with your Sandbox domain. Click here to view instructions for creating a new site for S-Sign.

After recreating your S-Sign site, you'll need to provide S-Sign with your site's information and assign guest user permissions once more. Click here to view instructions.


Restrict A Template From Being Emailed

By Best Practices, Documentation, S-Docs Cookbook No Comments

Use Email Settings To Restrict A Template From Being Emailed

Although S-Docs will show the Email Selected Docs button by default after a document has been generated, it is possible to hide this button and disable a template's ability to be emailed. There are many reasons that an admin might want to restrict templates from being emailed; for example, if a document contains potentially sensitive information, it might be easier to avoid mistakes by taking away the email option entirely.

To accomplish this, navigate to the template editor for the template that you want to restrict from being emailed.

Next, navigate to the Email Settings tab.

Finally, check the Lock To box, and leave the To field blank. Once you click Save, the template will no longer be able to be emailed.

What The End User Will See

When the document is generated, the Email Selected Docs button will be gone.

If multiple S-Docs are generated, and some of them can be emailed, the ones that you restrict will have a lock icon.

Keep in mind that this must be done for every template you want to restrict from being emailed. If you would like to learn more about the S-Docs template editor, please visit our template editor guide and our guide to email templates in S-Docs.


Moving S-Docs Templates from Sandbox to Production

By Best Practices, Documentation, S-Docs Cookbook No Comments

Video Tutorial

Import Templates With The S-Docs Template Migrator

Moving S-Docs templates from your Salesforce sandbox org to your Salesforce production org is easy with the S-Docs Template Migrator. The Template Migrator will generate a .zip file of templates that can be imported into any org of your choosing. If your template contains attachments (such as DOCX templates), those will be included as well. If any of your templates are S-Sign enabled, the S-Sign data will also be preserved. Let's take a look at how this works.

Note: S-Docs 4.210 or higher is required to use the S-Docs template migrator. S-Sign version 2.78 or higher is required to migrate S-Sign templates.

If you are using S-Docs 4.381+, navigate to the S-Docs template migrator by clicking the App Launcher, typing "S-Docs," and clicking S-Docs Setup in the dropdown menu. Scroll down to the Migrate S-Docs & S-Sign Templates section and click Go To S-Docs Migration Page.

If you are using a version of S-Docs below 4.381, navigate to the template migrator by appending the following after "salesforce.com" in your browser:

[code lang="html"]/apex/SDOC__SDMigrate[/code]

You'll be presented with this screen.

This page has two sections: Import and Export. We'll look at Export first.

Export Templates

The template Export section appears as follows:

To generate a list of templates to export, begin by [1] setting filters for which templates should be included. Filters need to be written using SOQL syntax. The example above uses the following filter:

[code lang="html"]WHERE Document_Category__c='Contract'[/code]

This will generate a list of all templates with the Document Category field set to "Contract." [2] Click Set Export Filters to generate a list of all templates that meet the filter criteria.

 

Example Export Filters

The following table provides different SOQL filter syntax and what the template migrator will return. This list is not exhaustive and is only intended to provide samples of acceptable syntax.

Filter Output
WHERE Name LIKE '%Master Service Agreement%' All templates that contain 'Master Service Agreement' in the Template Name field.
WHERE Name='Quote' OR Name='Business Proposal' All templates with a Template Name of "Quote" or "Business Proposal.'
WHERE Base_Object__c='Opportunity' ORDER BY CreatedDate DESC LIMIT 5 The 5 most recently created templates with a Related To Type field set to "Opportunity."
WHERE Name IN ('Invoice','Standard Invoice','Invoice - By Product') All templates with a Template Name equal to exactly "Invoice," "Standard Invoice," or "Invoice - By Product."
Note: If you do not specify any filters, clicking Set Export Filters will generate a list of every S-Docs template in your org.
Note 2: To find a list of field API names for the SDoc Template Object, navigate to Setup > Object Manager > SDoc Template > Fields & Relationships. Note that most fields are preceded by the SDOC__ namespace prefix; be sure to omit this prefix when including fields in your filter.

After clicking Set Export Filters, every template that meets your filter criteria will be [1] added to the table at the bottom of the page. This table displays the Template Type, Template Name, and Template ID fields. If your S-Docs template is S-Sign enabled, a separate S-Sign template will be included with it; when you import these templates into a production org, they will be recombined into a single template. You can [2] use the checkboxes on the right to manually include or exclude certain templates from your export.

[3] Click Generate Export Zip to generate a .zip file that contains all of your templates. If you'd like to exclude data from individual template fields from being carried over, you can [4] check the Exclude SDOC Template Fields? box. This will open up a new menu.

Exclude SDOC Template Fields

The Exclude SDOC Template Fields menu appears as follows:

To exclude data from individual fields in your template export, [1] select the field on the left and [2] use the arrow keys to add it to the exclusion list on the right. If you select Template Name, for example, all of your templates will be imported into your production org without names.

If you want to preserve these settings (i.e. you want to exclude the same fields every time you export templates), you can [3] enter a file name and click Download Current Settings to download the settings as a .txt file. When you need to export templates again, you can [4] select Choose File and upload the .txt settings file.

Note: The Download Current Settings button will also save any filters that you used to generate your list of templates for export.

Import Templates

The template Import section appears as follows:

Click Choose File to select an exported .zip file of S-Docs templates.

When you upload your template file, [1] each template will be added to the template table at the bottom of the Import section. Just like in the Export section, you can view the Template Type, Template Name, and Template ID fields. [2] Click Start Import to import your templates. You can also [3] set certain field values for your templates before importing them by checking the Set SDOC Template Values? checkbox. This will open up a new menu.

Set SDOC Template Values

To begin, [1] click Add Field/Value. [2] A picklist of template fields will appear underneath, along with a text field where you can set the field data. In the example above, the Template Name field of each imported template will be changed to "Imported Template." Click Add Field/Value again to set additional fields.

Note: Set Boolean fields (such as Allow Edit) using True or False.

If you want to preserve these settings (i.e. you want to set the same field values every time you import templates), you can [3] enter a file name and click Download Current Settings to download the settings as a .txt file. When you need to import templates again, you can [4] select Choose File and upload the .txt settings file.

After your import is complete, a success message will appear under the Start Import button.

Template Migrator Considerations

  1. If you're migrating PDF-Upload templates that were created prior to S-Docs version 4.210, you'll need to convert any images that are present in them to Attachments. Previous versions of S-Docs stored these images as Documents, but the template migrator will only be able to export and import PDF-Upload templates that store images as Attachments. To convert older PDF-Upload templates, append the following URL after "Salesforce.com" in your browser:
    /apex/SDOC__SDMigrate?convertPDFPageImages=true
    This will add a Convert PDF Page Images button to the template migrator that will convert all PDF-Upload images to Attachments for you.
  2. The template migrator uses a field called Org_Agnostic_ID__c that doesn't change when it's migrated across orgs. This allows the template migrator to update a template that already exists in the production org when migrating the corresponding template from the sandbox org, rather than re-inserting the template and ending up with duplicates in the production org. If you've previously transferred templates using a utility other than this one (e.g. Data Loader), the templates you migrated will not have an Org-Agnostic ID in the production org, and hence won't be updated when you upload an export that includes the corresponding templates from another org; rather, the templates in the export will just be inserted and you'll end up with duplicates. In this case, you can delete all of the templates from the production org, then perform an import using this tool.

Import Templates Individually

If you created only a few (i.e. less than 15) S-Docs templates in your sandbox that you would like to move to your production org, you can import each template individually.

Import Templates Using Data Loader

You can also use the Salesforce Data Loader to import a large number of templates, although this method is not recommended -- the S-Docs template migrator is best practice for importing or exporting a large number of templates. If you want to use data loader, follow the steps below:

  1. Using DataLoader, export all SDoc Template records and fields from your sandbox org.
  2. Edit the resultant CSV and perform the following:
    1. Remove the row with NAME = "License Key"
    2. Remove all ID field columns (ID, CREATEDBYID, LASTMODIFIEDBYID, OWNERID, SDOC__Component_IDs__c, SDOC__Preview_Id__c, and SDOC__Master_Template__c)
    3. Remove all Date field columns (CREATEDBYDATE, LASTMODIFIEDDAE, LASTACTIVITYDATE, SYSTEMMODSTAMP, etc.)
    4. Remove all ENCODE field columns (SDOC__Template_XML_Encode__c, SDOC__Template_XML_Encode10__c, SDOC__Template_XML_Encode2__c, SDOC__Template_XML_Encode3__c, SDOC__Template_XML_Encode4__c, SDOC__Template_XML_Encode5__c, SDOC__Template_XML_Encode6__c, SDOC__Template_XML_Encode7__c, SDOC__Template_XML_Encode8__c, SDOC__Template_XML_Encode9__c, SDOC__Terms_XML_Encode__c)
    5. Remove all formula (SDOC__Format_Icon__c, SDOC__Restore_Link__c)
  3. Save as import CSV.
  4. Using DataLoader, insert the import CSV file from Step 3 into SDoc Template on your production org.
  5. Open Developer Console on your production org. Insert and execute the following in an Execute Anonymous window:
    [code lang="html"]update [SELECT Id FROM SDOC__SDTemplate__c WHERE Name != 'License Key' ORDER BY SDOC__Template_Format__c];[/code]

    Note: If you have more than 100 templates you may need to add LIMIT 100 OFFSET 0 to the SELECT statement and execute the update multiple times, incrementing the OFFSET value by 100 each time until all templates have been updated.

Discussion

If your templates make references to data (images, related lists, etc.) in your sandbox, these references still might work in your production instance. This is because templates in production are still able to use data from sandboxes. This is undesirable behavior; if you change/delete your sandbox, or change/delete certain data in your sandbox, then these references will no longer work.

We recommend pointing image references in your sandbox templates directly to image URLs in your production org. If you do this, you won't need to update any of your images once you move your sandbox templates into your production org.

We strongly recommend that you recreate all other types of sandbox data in your production org. After importing your templates into your production org from your sandbox, you can then proceed to update your templates to reference the data in your production org, rather than the data in your sandbox org.


Choosing between PDF, HTML, DOC, DOCX, or XLS formats

By Best Practices, Documentation, S-Docs Cookbook No Comments

Introduction

There are a multitude of different output types that S-Docs templates support. This document will go through five common ones and explain when to choose each one.

Some document formats are better suited for certain document types. For example, PDFs typically work best for contracts since you do not expect users or clients to edit them after generating (although S-Doc PDFs can be edited if the "Allow Edit" feature is enabled). As an administrator, you should select the right format based on how you expect the document to be viewed, used and distributed.

You must select one output format for each template. If you want to give your users control of the format, you can simply clone your template several times and save each version with a different output format. If all the versions are made active, the user could then choose the template with their desired output format.

PDF

PDF documents created with S-Docs are self-contained. By this, we mean that the complete content is stored within the document rather than using links that retrieve content when the document is opened. Therefore, internet connectivity is not needed to view any embedded images and using relative links do not pose a problem. Since the PDF is viewed using a Reader, the output is very consistent and predictable even across mobile clients. Although S-Docs allows you to choose whether or not your users can edit documents (including PDFs) after they have been generated, if you keep this option disabled, editing PDFs can be difficult, meaning it is a good choice when you do not want the user to edit the document after it has been generated. Therefore, this output is well suited for documents like quotes, contracts, or product information sheets.

However, rendering in PDF does have some design considerations. Specifically, not all fonts are supported, nor are all CSS styles. To get the desired result, you may need additional editing time or are afforded some leeway on the final output.

If you have existing company PDFs that you would like to use with S-Docs, you can leverage the PDF-Upload feature to upload your documents and drag and drop merge fields onto them. However, uploaded PDFs have certain limitations; namely, they do not support related lists.

To work around PDF-Upload limitations, you can convert your existing PDF to HTML so that it can be saved as an S-Docs template. Adobe provides free automatic conversion tools that can be found here: http://www.adobe.com/products/acrobat/access_onlinetools.html. You may need to edit the template after conversion in order to make it appear as the original.

DOC & DOCX

The DOC and DOCX formats are often the best choice for rendering form letters, especially when the message needs to be tailored for each document, such as customer service letters or meeting follow-ups. These formats are often used when there is a need to uniquely edit or personalize each document after it has been created.

Although both templates are output as Microsoft Word files, DOC templates are configured and edited within the S-Docs template editor, while DOCX templates are configured and edited within Microsoft Word and then uploaded to the S-Docs template editor.

DOC Templates

DOC templates are great if your document is very large or needs to include a lot of data-driven formatting. Since they're built and edited within the S-Docs template editor, there's a lot more flexibility when it comes to things like custom related list tables.

When you generate DOC templates, S-Docs uses the template definition you provide to create a new DOC file. You don’t need to configure a connector, plug-in, or any macros. This means you cannot use an existing DOC file (however, you can use the Paste From Word button to copy content from an existing DOC file into the template editor). After generating the document, the user can then leverage all the features of MS Word to further tailor the content of each message.

The following special S-Docs syntax can be used to insert a table of contents in your DOC template:

##TOCSTART## and ##TOCEND##

DOCX Templates

DOCX templates are built entirely within Microsoft Word and then uploaded to S-Docs. They're great for documents with a lot of non-data-driven formatting, since you can leverage the full feature functionality of Microsoft Word to easily insert tables, tables of contents, and other elements. The DOCX format is useful for users who are already proficient in Microsoft Word.

S-Docs elements like merge fields, related lists, and conditional logic can be included in your DOCX templates as well -- users simply need to copy syntax from the S-Docs template editor and paste it into their Microsoft Word document within square brackets.

Please refer to this documentation for important information regarding DOCX syntax and generation.

For templates with complex, data-driven formatting requirements, the DOC type should be used instead of DOCX, since more complex formatting is only supported within the S-Docs template editor.

XLS

For large related lists, you may want to render your document using the XLS file type. After a user creates the S-Doc, they can update the spreadsheet as usual.

Note: Similar to how S-Docs generates a DOC document, S-Docs does not populate an existing XLS file with data, but rather generates a new XLS file. This means that you do not need to create and share a template XLS file. All definitions and formulas should be defined in either Salesforce formula fields, or alternatively, using the S-Docs template editor. If you have existing XLS documents you want to use with S-Docs, you will need to save them as HTML and use the HTML output as the basis for your S-Docs template. You may need to remove some special formatting Microsoft automatically adds to the document that prevents non-Microsoft browsers from rendering the document correctly. There are also tools available online for converting Excel to HTML.

Tip

Since it is often difficult to predict a particular cell location that your S-Docs field will render to in MS Excel, and since many formulas require cell locations, it is often easier to create formulas using a two step process. First, you create your fields and render the document without any formulas. Then, once you have identified all your target cell locations, you can add your excel formulas using the S-Docs Template Editor.For example, typing the following text into the S-Docs template editor will sum the values of the contents of rows 4 through 8 in Column A.

=SUM(A4:A8)

You can also use a VLookup function to help locate values you want to update with Salesforce data. Here is a useful resource for creating Excel formulas: http://www.mrexcel.com/archive/Formulas/index.html

HTML

HTML is the most flexible of the output formats. HTML docs can even contain editable text areas. This is the format of choice if you wish to send an in-line document via email. However, you should note that images are retrieved when the document is viewed. For this reason, we do not consider the document "self-contained." This means users not only need to be connected to the internet to view your document appropriately, but also to have access to the embedded images. While embedded images can be useful for tracking, rendering consistent HTML on a variety of devices, browsers and email clients can also be challenging.

Note: If a user emails an HTML S-Doc during the last step of generation, S-Docs will automatically include the document in-line as HTML in the email body.

Using Images

If you are looking to embed images into your S-Doc, check out these guides on how to embed dynamic images or static images in your document.


Using S-Docs with Salesforce Chatter

By Best Practices, Documentation, S-Docs Cookbook No Comments

Introduction

Since S-Docs is a Native Force.com app, it integrates seamlessly with Salesforce Chatter.  Enabling Chatter on S-Docs will allow users to comment (Chatter) on specific S-Docs, and notify any user ‘following’ an S-Doc of changes. For general information on how to configure Chatter, please start with this Salesforce tutorial.

S-Docs uses a junction object (S-Docs Relationships) to relate generated S-Docs to your Salesforce records. When enabling S-Docs for Chatter, we recommend enabling the Chatter feed on the S-Docs Relationship object, not on the S-Doc object itself.

Enable Feed Tracking For The S-Doc Relationship Object

First, navigate to Build > Customize > Chatter > Chatter Settings and make sure the Chatter feature is enabled for your org. Next, navigate to Build > Customize > Chatter > Feed  Tracking. From here, select the “SDOC Relationship” object, as shown below:

Then, check Enable Feed Tracking to be able to select fields to track. Typically, customers will want to track just the “Status” and “Comment” fields, as these are the fields that are most meaningful to track. If you integrate S-Docs with an electronic signature solution like S-Sign, users could be notified via the Chatter feed that documents have been executed by the customer.

Create A Hyperlink On The S-Docs Related List

Now that you have Chatter enabled and Feed Tracking set, you will need to make one additional change. You will need to create a hyperlink on the S-Docs related list that can take the user to the S-Docs Relationship record detail page. This is the only page where users can click on the Follow button located on the Chatter toolbar.

Background: By default, there is no such hyperlink on the S-Docs related list, and this was done intentionally. While the S-Docs related list includes a column labeled “Document Number,” this field is a plain text field (not a hyperlink). If this field were a hyperlink, the user might expect this to open the S-Docs itself – not the S-Docs Relationship record. To eliminate any confusion, the hyperlink was intentionally removed.

However, for Chatter, we do need to get to the S-Docs Relationship record in order to allow users to click on the Chatter Follow button. Unfortunately, the first column in the related list (“Edit” link) won’t work either. While this link does take the user to the S-Docs Relationships page, it is rendered in edit mode, and the Chatter toolbar does not render for records in edit mode. So, you will need to add a new column to your S-Docs related list view that will take the user to the S-Docs Relationships record detail page.

While you might first consider using the Relationship ID field as an easier approach, this ID value would display the S-Doc Relationship ID, not the S-Doc ID, which again may confuse users. A formula field rendered as a hyperlink is the best solution. Since each org will have its own preference on how this related list column should appear, we have not included this formula field in the core S-Docs package, but rather leave it up to the Salesforce Admins to implement.

You will need to create this hyperlink using a custom formula field on the SDOC_Relationship__c object. You will then add this field to the related list view.

By using the formula below, you could include a new column that replaces “Document Number” with the same value but is a hyperlink to the S-Doc Relationship record. (For comparison only, both columns are included in the related list shown below.)

sdocs

Related List Columns

The table below describes the intended behavior we are seeking:

Column Click Action
Column 1 (Edit link) Open S-Docs Relationship record in edit mode. User can add/edit comments or change S-Doc status.
Column 3 (Excel icon) Opens the actual S-Doc in new window (e.g. launches MS Excel).
Column 5 (S-Doc Link) Opens S-Doc Relationship detail in same window. Users could then click on the “Follow” icon from the Chatter toolbar.

The example below uses an alternative link. The following formula will create a “Set Chatter Prefs” link field that you then add to the related list layout.
[code lang="html"]HYPERLINK('/'+ Id , “Set Chatter Prefs”, "_self" )[/code]
sdocs

Once you’ve added the link to the relationship object, the user simple opens the record and then clicks on the follow icon.

sdocs2


Updating templates without affecting previously created documents

By Best Practices, Documentation, S-Docs Cookbook No Comments

The S-Docs Solution Diagram

It is important to understand that once a template has been used to create the first "real" document, you should refrain from making ANY updates to the template. This is because the S-Docs template record is used both during document creation AND during each subsequent view of an S-Doc. Each S-Doc stores the template used to create it. If you attempt to open an S-Doc where the template used to create it has been deleted, you will receive an error. The diagram below illustrates this relationship.

solution-diagram

Use The "Auto Create Salesforce Attachment" Option

To edit templates without affecting previously created documents, you can use the Auto Create Salesforce Attachment and link to record option (found under the "Document Options" tab in the template editor, this feature is enabled by default). This feature creates an attachment each time a document is generated and stores it in the "Notes and Attachments" related list on the base object. Attachments allow you to store a copy of the document that cannot be affected by template changes and do not require the S-Docs template record to view. This is particularly useful for orgs that are restricted to 2 templates, have a need to change templates often, and still require past documents to remain unaffected by future template changes.

Cloning Templates

If you don't use the Auto Create Salesforce Attachment feature and want to make changes after you have completed your design work, it will affect how PREVIOUSLY generated documents are rendered. Therefore, if you need to make changes, you should CLONE the template and make modifications to the newly cloned record.

You then uncheck Available for use and Initially Visible on the original template to ensure no new document can be created using it.

Previously generated documents will continue to use the original template (therefore rendering unchanged), and new documents will use the newly activated template.


Top