Migrate Templates Between Orgs

Video Tutorial

Import Templates With The S-Docs Template Migrator

Moving S-Docs templates between Salesforce orgs 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:


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:

WHERE Document_Category__c='Contract'

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 TypeTemplate 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 any template attachments (for example, the uploaded PDF for PDF-Upload templates), you can [4] check the Exclude Attachments? checkbox. Note that you must re-upload any attachments upon import into a new org, and other data may be lost. This method is not recommended for most cases.

If you'd like to exclude data from individual template fields from being carried over, you can [5] check the Exclude SDOC Template Fields? checkbox. 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.

Note that you can also check the View all Createable/Modifiable fields? checkbox on the right of the Export section to view all template fields names and API names.

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 TypeTemplate 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:
    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)
    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:
    update [SELECT Id FROM SDOC__SDTemplate__c WHERE Name != 'License Key' ORDER BY SDOC__Template_Format__c];
    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.


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.

Was this helpful?