Source: https://vaultcrmhelp.veeva.com/doc/Content/CRM_topics/Multichannel/ApprovedEmail/CreatingContent/InsertingQueriedData.htm

## Inserting Queried Data into an Approved Email

Content creators can use the {{customContent}} token to query information from Vault CRM and add that information to content, greatly enhancing flexibility when adding information to content.

The token can directly reference any field of a supported object reference field type, along with retrieving values from .txt attachment fields.

**Who can use this feature?**

* Content Creation Users — Browser, iPad, iPhone
* [Using the Custom Content Token](#Using)
* [Marking the Custom Content Token as Required](#Marking)
* [Inserting Attachment Field Values Using the Custom Content Token](#Inserting)
* Users require an Approved Email license

### Configuring Attachment Fields for the Custom Content Token for

[![Closed](../../../../../Skins/Default/Stylesheets/Images/transparent.gif)Content Creation Users](#)

Attachment field functionality in the {{customContent}} token requires additional configuration. The attachment fields must sync to the device for the token to reference their values in Approved Email. To ensure specific attachment fields are synced to the device, administrators can specify them in the Include Attachment Field List field on the object's VMOC.

To configure this feature:

1. Navigate to **Admin > Configuration > Objects > VMobile Object Configuration > Layouts**.
2. Add the **Include Attachment Field List** (include\_attachment\_field\_list\_\_v) field to the appropriate object layouts.
3. Navigate to **Admin > Users & Groups > Permission Sets**.
4. Select the appropriate permission set.
5. Select the **Objects** tab.
6. Grant the following permissions:

   | Object | Object Permission | Object Type | Fields | Field Permission |
   | --- | --- | --- | --- | --- |
   | vmobile\_object\_configuration\_\_v | CRE | tablet\_\_v | * include\_attachment\_field\_list\_\_v | Edit |

[![Closed](../../../../../Skins/Default/Stylesheets/Images/transparent.gif)End Users](#)

To configure this feature:

1. Navigate to **Admin > Users & Groups > Permission Sets**.
2. Select the appropriate permission set.
3. Select the **Objects** tab.
4. Grant the following permissions:

   | Object | Object Permission | Object Type | Fields | Field Permission |
   | --- | --- | --- | --- | --- |
   | vmobile\_object\_configuration\_\_v | R | tablet\_\_v | * include\_attachment\_field\_list\_\_v | Read |
5. Navigate to **Business Admin > Objects > VMobile Object Configurations**.
6. Select the VMOC linked to the object whose attachment fields are used in the Custom Content token.
7. Select **Edit**.
8. Enter the attachment fields in the **include\_attachment\_field\_list\_\_v** field using a double semi-colon delimited list. This list is case-sensitive.
9. Ensure the VMOC is Active.
10. Select **Save**.

### Using the Custom Content Token as

[![Closed](../../../../../Skins/Default/Stylesheets/Images/transparent.gif)Content Creator Users](#)

The {{customContent}} token uses a SQL-like querying language. The WHERE clause can reference any supported [merge token](ConfigTokens.htm#mergeToken) field from the following Vault CRM objects using the {{ObjectName.FieldName}} format:

* account\_\_v
* address\_\_v
* approved\_document\_\_v (only supported in email template)

The token uses the general format:

```
{{customContent[QUERY]}}
```

Where QUERY is replaced by a SQL-like query using the = operator.

For example:

[Copy](javascript:void(0);)

```
{{customContent[SELECT field__c FROM my_object__c where zip__c = '{{address__v.zip__v}}' and product__c = 'Cholecap']}}
```

The returned value is stored in the email\_config\_value\_\_v field on the sent\_email\_\_v object. If multiple results are returned, the first result is stored.

Addresses marked as Primary Addresses always return first if they match the query.

The token is case-sensitive, and should not contain extra spaces.

Ensure end users have at least Read field permission to all fields referenced by this token.

#### Marking the Custom Content Token as Required

The custom content token can be marked as required by adding :Required after the query:

[Copy](javascript:void(0);)

```
{{customContent[QUERY]:Required}}
```

Emails cannot be sent if a required token returns NULL.

#### Inserting Attachment Field Values Using the Custom Content Token

The {{customContent}} token can access data stored in a plain text file (extension .txt) in an attachment type field on any object to be inserted into the email. This plain text can consist of HTML tags. The HTML is rendered with the appropriate styling once inserted into the email.

The file in the attachment type field must be a .txt file under 1.2MB. Other file types do not return a value and the token is rendered as an empty string in the email.

Using the {{customContent}} token to access attachment type fields is supported in Email Templates, Email Fragments, and Template Fragments.

Inserting Attachment Field Values Using the Custom Content Token is not supported in receipts and double opt-in/consent confirmation emails.

For example, formulary\_table\_\_c is an attachment field on the formulary\_data\_\_c object. This field is used to store the formulary\_table.txt file, which contains HTML used to render a formulary table personalized for an account.

The following token retrieves the HTML from the formulary\_table.txt file stored in the formulary\_table\_\_c attachment field. This HTML is inserted into the email content to display the formulary table:

[Copy](javascript:void(0);)

```
{{customContent[SELECT formulary_table__c FROM formulary_data__c where account__c = '{{account__v.id}}']}}
```

### Related Topics

[Approved Email Configuration Tokens](ConfigTokens.htm)
