> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/template-architecture/template-settings/document-options-tab/how-to-auto-attach-documents-to-records.md).

# How to Auto-Attach Documents to Records

Save generated documents to Salesforce Files or Attachments automatically.

Use auto-attach settings to save documents without manual user steps.

This keeps record files consistent and reduces missed saves.

### Choose how S-Docs saves the generated file

{% stepper %}
{% step %}

### Open document options

Open the **Document Options** tab.
{% endstep %}

{% step %}

### Go to attachment and file options

Find **Attachment & File Options**.
{% endstep %}

{% step %}

### Select a save method

Choose one of the available save options.
{% endstep %}

{% step %}

### Save the template

Save your changes.

Generate a test document.
{% endstep %}
{% endstepper %}

### Available save options

* **Create Salesforce File and link to record** — recommended for most orgs.
* **Create Salesforce Attachment and link to record** — useful for legacy setups.
* **Create Salesforce Attachment only when emailed** — saves storage for draft-heavy workflows.

### Control deletion behavior

By default, related files or attachments can be removed when the S-Doc record is deleted.

Clear **Delete related Salesforce Attachment/File upon S-Doc deletion** if you need to preserve generated files for audit or retention purposes.

### Files vs. Attachments

| Feature    | Salesforce Files        | Salesforce Attachments |
| ---------- | ----------------------- | ---------------------- |
| Interface  | Lightning-ready         | Legacy                 |
| Versioning | Supported               | Not supported          |
| Sharing    | Better sharing controls | Basic                  |
| Best fit   | New implementations     | Legacy integrations    |

{% hint style="info" %}
Use **Salesforce Files** for most new implementations.
{% endhint %}

{% hint style="warning" %}
Both Files and Attachments count toward Salesforce storage limits.

Review storage usage if you generate documents at high volume.
{% endhint %}

### When to use each option

#### Use Salesforce Files

Use this when your org works primarily in Lightning.

This is the best default for modern document management.

#### Use Salesforce Attachments

Use this only when another process still depends on legacy attachments.

#### Use attachment on email only

Use this when many generated documents are drafts and only emailed copies need to persist.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.sdocs.com/sdocs/template-architecture/template-settings/document-options-tab/how-to-auto-attach-documents-to-records.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
