> 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).

# How to Auto-Fill Customer Data into Templates

Use this tutorial when you need to place live Salesforce data into a PDF template.

## What it looks like

After setup, one generated PDF can show all of this:

* Record data in fixed spots on the page
* Different values for each Salesforce record
* Reusable field placement across similar templates

This is the right starting point for forms, welcome packets, and branded PDFs.

## What merge fields do

Merge fields pull data from Salesforce into the generated document.

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 name
* Billing address
* Opportunity amount

## How merge fields work with S-Docs

S-Docs uses the 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 template, you usually select the field in the editor instead of typing the syntax yourself.

S-Docs builds the field for you and lets you place it on the PDF canvas.

## Merge field syntax

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

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

{% hint style="info" %}
In PDF-Upload templates, the field picker usually generates the merge field for you.
{% endhint %}

## Insert a merge field into a PDF template

### What you'll configure

* One PDF-Upload template tied to a Salesforce object
* One merge field placed on the PDF
* One test document to confirm the output

**Estimated time:** 10 minutes

### Prerequisites

Before you start, make sure you have:

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

{% stepper %}
{% step %}

### Step 1: Create or open a PDF-Upload template

1. Go to **S-Docs Templates**.
2. Open an existing template or click **New**.
3. Set **Related To Type** to the object you want, such as `Opportunity`.
4. Set **Template Format** to `PDF-UPLOAD`.
5. Save the template.

This gives S-Docs the record type and PDF format needed for drag-and-drop field placement.
{% endstep %}

{% step %}

### Step 2: Open the template editor and upload the PDF

1. Open the template.
2. Click **Template Editor**.
3. Click **Upload PDF File**.
4. Select your PDF.

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

Click on the link below to download a sample pdf file for reference.

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

{% step %}

### Step 3: 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 now builds the field for you from the selected Salesforce path.
{% endstep %}

{% step %}

### Step 4: Place the 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.

This tells S-Docs where to print the field value in the final PDF.
{% endstep %}

{% step %}

### Step 5: Save and test

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

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

## Common issues and solutions

<details>

<summary>"The field shows blank in the PDF"</summary>

Problem: The field is placed, but the generated PDF has no value.

Solution:

* Check that the source record has data in that field
* Confirm the template uses the correct **Related To Type**
* Reinsert the field if you selected the wrong path

</details>

<details>

<summary>"I need data from a related record"</summary>

Problem: The base record is correct, but the value lives on a parent record.

Solution:

* Use the field picker to expand related records
* Choose a path such as `Opportunity.Account.Name`
* Test with a record that actually has that relationship populated

</details>

<details>

<summary>"The value placement looks off on the page"</summary>

Problem: The value prints, but the placement is hard to read.

Solution:

* Move the field to a wider area on the PDF
* Test with shorter sample values first
* Split long content across separate fields when needed

</details>

## What you've learned

✅ What merge fields are used for\
✅ How S-Docs resolves merge fields from Salesforce data\
✅ The basic merge field syntax\
✅ How to place a merge field on a PDF-Upload template

## Next steps

* Use [Template Attributes Tutorial](/quick-start/template-building/how-to-format-text-dates-and-currency.md) when you need to format values.
* Use [Create Your First Template](/quick-start/getting-started/create-your-first-template.md) if you want the full PDF-Upload setup flow.
* Use [Getting Started with Conditional Logic](/quick-start/template-building/conditional-logic-tutorial.md) when content should appear only for some records.

## Practice exercise

1. Add `Opportunity.Name` to a PDF 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 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/quick-start/template-building/how-to-auto-fill-customer-data-into-templates.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.
