---
title: "Merge Fields - Appiphony"
url: "https://appiphony.com/docs/drive-connect/features/document-generation-legacy/document-generation/merge-fields"
---

# Merge Fields

Drive Connect's **Template Builder** utilizes merge fields to pull data from Salesforce records and insert it into a Google Drive document.

Merge fields power document generation and enable Salesforce users to create up-to-date and accurate documentation. They pull predefined data already available inside a Salesforce record and its related records and insert them into a new Google document, allowing for the accurate and rapid generation of important documentation.

1. Navigate to the **Drive Connect** application in Salesforce and select the **Template Builder** tab. ![Drive Connect app with Template Builder tab highlighted](https://appiphony.com/wp-content/uploads/2024/05/Drive-Connect-app-with-Template-Builder-tab-highlighted-4.png)
2. Create a new template or select an existing template to edit. ![Template Builder tab with templates folder edit UI highlighted](https://appiphony.com/wp-content/uploads/2024/05/Template-Builder-tab-with-templates-folder-edit-UI-highlighted.png)
3. On the merge field generator tab, click the **Type** drop-down and select **[Record] Fields & Related Objects.** ![Merge Field Generator tab within template editor with Type picklist visible and Fields and Related Objects option selected](https://appiphony.com/wp-content/uploads/2024/05/Merge-Field-Generator-tab-within-template-editor-with-Type-picklist-visible-and-Fields-and-Related-Objects-option-selected.png)
4. In the second drop-down menu, select **a field** or **related object**. Related objects will be located lower than the record field selections on the list. Select the related object and continue to scroll down until you find the field that you are looking for. ![Merge Field Generator tab within template editor with Function picklist highlighted and Conditional Logic option selected](https://appiphony.com/wp-content/uploads/2024/05/Merge-Field-Generator-tab-within-template-editor-with-Function-picklist-highlighted-and-Conditional-Logic-option-selected.png)
5. Once you have made your selection, copy and paste it into the appropriate section of your merge template. ![Merge Field editor with generated merge field pasted into template](https://appiphony.com/wp-content/uploads/2024/05/Merge-Field-editor-with-generated-merge-field-pasted-into-template.png)

### Lookup Merge Fields

1. Navigate to the **Drive Connect** application in Salesforce and select the **Template Builder** tab.![Drive Connect app with Template Builder tab highlighted](https://appiphony.com/wp-content/uploads/2024/05/Drive-Connect-app-with-Template-Builder-tab-highlighted-4.png)
2. Create a new template or select an existing template to edit. ![Template Builder tab with templates folder edit UI highlighted](https://appiphony.com/wp-content/uploads/2024/05/Template-Builder-tab-with-templates-folder-edit-UI-highlighted.png)
3. On the merge field generator tab, click the **Type** drop-down and select **[Record] Fields & Related Objects.** ![Merge Field Generator tab within template editor with Type picklist visible and Fields and Related Objects option selected](https://appiphony.com/wp-content/uploads/2024/05/Merge-Field-Generator-tab-within-template-editor-with-Type-picklist-visible-and-Fields-and-Related-Objects-option-selected.png)
4. In the second drop-down, select a lookup from the field section denoted by a right-facing karat (**>**). ![Field or Related Object picklist with lookup field selected](https://appiphony.com/wp-content/uploads/2024/05/Field-or-Related-Object-picklist-with-lookup-field-selected.png)
5. A third dropdown will appear. From here, select the desired field or select another lookup and select the field from the next dropdown that appears. ![Field or Related Object picklists with field selected in the third picklist](https://appiphony.com/wp-content/uploads/2024/05/Field-or-Related-Object-picklists-with-field-selected-in-the-third-picklist.png)
6. Once you have made your selection, copy and paste it into the appropriate section of your merge template. ![Generated merge field pasted into body of template](https://appiphony.com/wp-content/uploads/2024/05/Generated-merge-field-pasted-into-body-of-template.png)

### Merge Fields in File Names

Adding merge fields to a file’s **Generated Name** field will enable generated documents to have names that include Salesforce data. This can help you identify generated documents when viewing them outside of Salesforce.

1. Navigate to the **Drive Connect** application in Salesforce and select the **Template Builder** tab. ![Drive Connect app with Template Builder tab highlighted](https://appiphony.com/wp-content/uploads/2024/05/Drive-Connect-app-with-Template-Builder-tab-highlighted-4.png)
2. Create a new template or select an existing template to edit. ![Template Builder tab with templates folder edit UI highlighted](https://appiphony.com/wp-content/uploads/2024/05/Template-Builder-tab-with-templates-folder-edit-UI-highlighted.png)
3. On the merge field generator tab, click the drop-down and select **[Record] Fields & Related Objects.**
4. In the second drop-down, **select** **a field**, **lookup**, or **related object**. Related objects will be located lower than the record field selections on the list. Select the lookup or related object and continue to scroll down until you find the field that you are looking for.
5. Once you have made your selection, copy and paste it into the generated name field of the template editor. ![Merge field pasted into Generated Name input at top of editor](https://appiphony.com/wp-content/uploads/2024/05/Merge-field-pasted-into-Generated-Name-input-at-top-of-editor.png)

### Date of Merge Function Fields

Template builders can add merge fields that reference date and date/time to merge templates. By adding date and date/time merge fields to a merge template, template builders can ensure that date-sensitive documentation always contains the correct date to avoid possible customer service and/or legal disputes.

1. Navigate to the **Drive Connect** application in Salesforce and select the **Template Builder** tab. ![Drive Connect app with Template Builder tab highlighted](https://appiphony.com/wp-content/uploads/2024/05/Drive-Connect-app-with-Template-Builder-tab-highlighted-5.png)
2. Create a new template or select an existing template to edit. ![Template Builder tab with templates folder edit UI highlighted](https://appiphony.com/wp-content/uploads/2024/05/Template-Builder-tab-with-templates-folder-edit-UI-highlighted-1.png)
3. In the merge field generator, select the **Type** drop-down and select **Functions**.![Merge field generator with Functions option selected](https://appiphony.com/wp-content/uploads/2024/05/Merge-field-generator-with-Functions-option-selected.png)
4. In the **Function** drop-down, select **Date of Merge**. ![Merge field generator with Date of Merge selected in Function picklist](https://appiphony.com/wp-content/uploads/2024/05/Merge-field-generator-with-Date-of-Merge-selected-in-Function-picklist.png)
5. In the **Day Offset** field, enter a value **greater than or equal** to zero. ![Day offset field set to 30 days after date of merge](https://appiphony.com/wp-content/uploads/2024/05/Day-offset-field-set-to-30-days-after-date-of-merge.png)
6. In the **Date Format** dropdown, select the format that best fits your use case. ![Date format picklist with three options visible](https://appiphony.com/wp-content/uploads/2024/05/Date-format-picklist-with-three-options-visible.png)
7. Once you have formatted your date or date/time merge field, copy and paste it into the appropriate section of your merge template. ![Merge field pasted into due date section of invoice template](https://appiphony.com/wp-content/uploads/2024/05/Merge-field-pasted-into-due-date-section-of-invoice-template.png)
