> 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

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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
