# Template Lifecycle Management

Once you have perfected a template in your Salesforce Sandbox, you need a safe and reliable way to move it into your Production environment (or share it with another org entirely). S-Docs makes this easy by allowing you to export your entire template configuration as a portable text string.

***

### How to Export a Template

Exporting a template packages its entire structure—including the HTML body, page settings, email configurations, and runtime prompts—into a single JSON text string.

1. Open the template you want to export and click into the Template Editor.
2. Navigate to the Advanced Options tab.
3. Under the "Export Template" section, click the Generate button.
4. A large text box will appear containing a long string of JSON code.
5. Click Copy (or manually select all the text and copy it).
6. Paste this text into a plain text file on your computer (e.g., Notepad or TextEdit) and save it.

> Best Practice for Version Control: Save your export files with a strict, descriptive naming convention so you can track your changes over time. For example: `QuoteTemplate_v1.0_2024-02-04_Initial.txt` or `QuoteTemplate_v1.1_2024-02-15_AddedPrompts.txt`.

***

### How to Import a Template

To bring your exported template into a new environment, you simply need to paste that JSON code into the target org.

1. Log into your Target Org (e.g., your Production environment).
2. Navigate to the S-Docs Templates tab and click the New Template button.
3. Look for the Import option. *(Note: Depending on your specific S-Docs version, this may be located on the template list view, the template detail page, or the initial creation screen).*
4. Paste the entire JSON string you copied during the export process.
5. Click Import or Create Template.

Your template will instantly generate with all of your settings and content intact!

***

### The Migration Checklist

Because no two Salesforce orgs are exactly identical, you must ensure your Target Org is prepared to receive the template.

### What Migrates vs. What Doesn't

| **Automatically Included in Export**  | **NOT Included (Must be manually recreated)** |
| ------------------------------------- | --------------------------------------------- |
| Template body (HTML/CSS)              | Actual Salesforce record data                 |
| Page, Document, and Task Settings     | Template permissions and sharing settings     |
| Email Settings & Runtime Prompts      | S-Docs button configurations                  |
| Formatting, styling, and merge fields | Org-specific IDs (like a Preview ID)          |

### Pre-Import Prerequisites

Before you hit "Import" in your new org, verify the following elements exist:

* Custom Fields & Objects: All custom fields and objects referenced in your template *must* exist in the target org. The API names and field types must match exactly.
* Record Types: If your template relies on specific record types, their Developer Names must match.
* S-Docs Version: Ensure the target org has the same (or a compatible) version of S-Docs installed.

### Post-Import Configuration

Immediately after importing, you need to reconfigure any settings that rely on org-specific data:

1. Update Org-Wide Emails: If your template sends from a generic company address, you must reselect that verified address in the target org's Email Settings tab.
2. Update the Preview ID: Your old test record ID from the Sandbox does not exist in Production! Find a valid record ID in your new org and paste it into the Advanced Options tab to restore your preview functionality.
3. Test End-to-End: Always generate a test document, verify the merge fields populated correctly, and send a test email to ensure your routing is working.

***

### Troubleshooting Common Import Errors

| **Error Message**          | **Why it Happened**                                                        | **How to Fix It**                                                                                                        |
| -------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| "Field does not exist"     | The target org is missing a custom field referenced in the template.       | Create the missing custom field in Salesforce with the exact same API name, or delete the merge field from the template. |
| "Invalid org-wide address" | The sender address verified in your Sandbox is not verified in Production. | Recreate and verify the Org-Wide Address in Salesforce Setup, then reselect it in the Template Editor.                   |
| "Record type not found"    | The target org is missing a record type used by your template.             | Recreate the record type in the new org, ensuring the Developer Name matches the original.                               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/template-architecture/template-settings/advanced-options-tab/template-lifecycle-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
