> 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/quick-start/template-building/how-to-auto-fill-customer-data-into-templates.md).

# Auto-fill customer data in Document Templates

Add Merge Fields to PDF-Upload Document Templates and generate documents with Salesforce record data.

Use this tutorial to place Salesforce record data into a PDF-Upload Document Template.

### Previewing Generated Output

After setup, each generated PDF can include:

* Record data in fixed page locations
* Different values for each Salesforce record
* Reusable field placement across similar Document Templates

Use this approach for welcome packets and branded PDFs.

### Understanding Merge Fields

Merge Fields pull Salesforce data into generated documents.

When S-Docs runs, it reads the source record, resolves each field path, and prints the value in the final output.

Common examples include:

* Customer names
* Billing addresses
* Opportunity amounts

### Understanding Merge Fields in S-Docs

S-Docs uses the Document Template's **Related To Type** as the starting object.

From there, it can pull fields from that record and related records, such as `Opportunity.Account.Name`.

In a PDF-Upload Document Template, select the field in the editor.

S-Docs creates the Merge Field and adds it to the PDF canvas.

### Using Merge Field Syntax

Use `{{!Object.FieldName}}` in the Document Template body to print one field value.

Example: `{{!Opportunity.Name}}`

{% hint style="info" %}
The field picker creates Merge Fields in PDF-Upload Document Templates.
{% endhint %}

### Add a Merge Field to a PDF-Upload Document Template

#### Reviewing the configuration

* One PDF-Upload Document Template tied to a Salesforce object
* One Merge Field placed on the PDF
* One test document to confirm the output

**Estimated time:** 10 minutes

#### Meeting prerequisites

Before you start, make sure you have:

* Access to **S-Docs Templates**
* Permission to create or edit Document Templates
* A PDF file ready to upload
* A test record with values you can verify

{% stepper %}
{% step %}

#### Create a PDF-Upload Document Template

1. Navigate to **S-Docs Templates**.
2. Click **New**.
3. Set **Related To Type** to the required object, such as `Opportunity`.
4. Set **Template Format** to `PDF-UPLOAD`.
5. Click **Save**.

S-Docs uses these settings for drag-and-drop Merge Field placement.
{% endstep %}

{% step %}

#### Upload the PDF

1. Open the Document Template.
2. Click **Template Editor**.
3. Click **Upload PDF File**.
4. Select the PDF file.

The PDF appears on the canvas. The field tools appear on the left.

Download the sample PDF file for reference.

{% file src="/files/xk7rv0Lq1oaDi88B8YdL" %}
{% endstep %}

{% step %}

#### Create a Merge Field

1. In **S-Docs Fields**, click **Create Another Field**.
2. Select **Merge Field**.
3. Click **Select Merge Field**.
4. Choose a field, such as `Opportunity.Name` or `Opportunity.Account.Name`.
5. Click **Insert Field**.

S-Docs creates the Merge Field from the selected Salesforce path.
{% endstep %}

{% step %}

#### Place the Merge Field on the PDF

1. Find the generated field block in the left panel.
2. Drag it onto the PDF canvas.
3. Drop it where the value should appear.

S-Docs prints the field value in this location.
{% endstep %}

{% step %}

#### Test the Document Template

1. Click **Save**.
2. Open a test record for the same object.
3. Click **Generate Document**.
4. Confirm the PDF shows the expected value in the right spot.

If the value is incorrect or blank, check the source record and field selection.
{% endstep %}
{% endstepper %}

### Resolving Common Issues

### **The Merge Field shows blank in the PDF**

Verify that the source record contains data. Confirm **Related To Type** matches the source object. Reinsert the Merge Field if you selected an incorrect path.

### **You need data from a related record**

Expand related records in the field picker. Select a path such as `Opportunity.Account.Name`. Test with a record that includes the relationship.

### **The Merge Field placement looks incorrect**

Move the Merge Field to a wider PDF area. Test with shorter sample values. Split long content across separate fields when needed.

### Reviewing What You Learned

* Merge Fields add Salesforce data to generated documents.
* S-Docs resolves Merge Fields from Salesforce record data.
* PDF-Upload Document Templates support drag-and-drop Merge Field placement.

### Continuing to Related Tasks

* Use [How to Format Text, Dates, and Currency](https://help.sdocs.com/quick-start/template-building/how-to-format-text-dates-and-currency.md) to format values.
* Use [Create Your First Template](https://help.sdocs.com/quick-start/getting-started/create-your-first-template.md) for the full PDF-Upload setup flow.
* Use [How to Show or Hide Content Automatically](https://help.sdocs.com/quick-start/template-building/conditional-logic-tutorial.md) when content appears for selected records.

### Practicing Merge Field Placement

1. Add `Opportunity.Name` to a PDF-Upload Document Template.
2. Add `Opportunity.Account.Name` below it.
3. Generate the document from two different records and compare the output.


---

# 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/quick-start/template-building/how-to-auto-fill-customer-data-into-templates.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.
