> 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/inserting-merge-fields/special-merge-fields.md).

# Special Merge Fields

## Special Merge Fields

Use this page when you need values that do not live on the source record.

Special merge fields pull data from the generated document, the generation context, or the current user.

Use them for document metadata, record ID formats, PDF page numbering, and user details.

### What you can do with special merge fields

* Show document values like ID, date, time, and format.
* Choose between 15-character and 18-character Salesforce record IDs.
* Add PDF page numbering and page counts.
* Output the generating user's name, email, department, or signature.

### When to use special merge fields

{% hint style="info" %}
Use a standard merge field when the value lives on the source record.
{% endhint %}

Use a special merge field when you need values like:

* the generated document ID
* the document date or time
* the 15-character or 18-character record ID
* page numbers in a PDF
* the generating user's email signature

### Special Merge Fields

| Merge Field                 | Output                                                                                    |
| --------------------------- | ----------------------------------------------------------------------------------------- |
| `{{!DocumentID}}`           | S-Doc ID of the generated document, such as `SD-174`. This is not a Salesforce record ID. |
| `{{!DocumentName}}`         | Value stored in the template's **Template Name** field.                                   |
| `{{!DocumentObject}}`       | Salesforce object type the document was generated for.                                    |
| `{{!DocumentDate}}`         | Date the document was generated.                                                          |
| `{{!DocumentDateSOW}}`      | Start-of-week date for the generated document.                                            |
| `{{!DocumentDateEOW}}`      | End-of-week date for the generated document.                                              |
| `{{!DocumentDateTime}}`     | Date and time the document was generated.                                                 |
| `{{!DocumentFormat}}`       | Output file type, such as `PDF` or `DOC`.                                                 |
| `{{!ObjectId18}}`           | 18-character Salesforce record ID for the source record.                                  |
| `{{!ObjectId15}}`           | 15-character Salesforce record ID for the source record.                                  |
| `{{!PageNumber}}`           | Current page number in the generated document.                                            |
| `{{!PageCount}}`            | Total page count in the generated document.                                               |
| `{{!UserFirstName}}`        | First name of the user who generated the document.                                        |
| `{{!UserLastName}}`         | Last name of the user who generated the document.                                         |
| `{{!UserName}}`             | Full name of the user who generated the document.                                         |
| `{{!UserOrganizationName}}` | Organization name of the user who generated the document.                                 |
| `{{!UserLoginName}}`        | Salesforce username of the user who generated the document.                               |
| `{{!UserEmail}}`            | Email address of the user who generated the document.                                     |
| `{{!UserDepartment}}`       | Department of the user who generated the document.                                        |
| `{{{!UserSignature}}}`      | Salesforce email signature of the user who generated the document.                        |

{% hint style="info" %}
`{{!PageNumber}}` and `{{!PageCount}}` are intended for PDF templates only.
{% endhint %}


---

# 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/inserting-merge-fields/special-merge-fields.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.
