# CRM Vault Metadata Sync

CRM Vault Metadata Sync gives you the option to have Veeva CRM manage CRM _Products_, _Directories_, _Surveys_, and _Content Types_ in Vault. This process provides the necessary objects, fields, and reference constraints to properly push and sync CRM metadata to your Vault.

Using this feature requires additional setup and integration in Veeva CRM.

## Integration

Currently, the integration for CLM, Approved Email, and Engage integration uses the _External ID_ of Vault's _Product_ object. When CRM Vault Metadata Sync is configured, CRM will push detail, detail topic, and detail group products into the CRM Product object. The integration between Vault and CRM can use either the current _Product_ object, or the _CRM Product_ object. In CRM, the field mappings for CLM, Approved Email, and Engage for Portals will be updated to show both CRM Product and Product.

During integration, CRM checks if the _CRM Product_ field is populated on the document first before checking the _Product_ field. If both fields are populated, CRM prioritizes _CRM Product_.

## CRM Vault Metadata Sync Objects

When you enable CRM Vault Metadata Sync, CRM will push CRM products from a specific _CRM Org_ into the following objects:

| Object | Description |
| --- | --- |
| CRM Products | CRM pushes all _Detail_ and _Detail product_ records to this object |
| CRM Detail Group Object | CRM pushes all _Detail Group_ product records into this object. |
| CRM Product Group | Join object for the many-to-many relationship between _CRM Detail Group_ and _CRM Products_. This stores the _Product_ relationship between the _Detail_, _Detail Topics_, and _Detail Groups_ objects.


## Document Fields {#doc_fields}

The following document fields appear on documents or binders when using CRM Vault Metadata Sync. All Multichannel document fields are [shared fields](/en/lr/4884/). Although these fields apply primarily to the _Multichannel Presentation_ and _Multichannel Slide_ document types, you can add the following document fields to any document type:

| Field | Document Type | Function |
| --- | --- | --- |
| CRM Org | Shared field | Filters CRM metadata. |
| CRM Product | Shared field | For integration with CRM. |
| CRM Product Group | Shared field | Select _Product Groups_. For integration with CRM. |
| CRM Detail Group | Shared field | Select _Detail Groups_. For integration with CRM. |

You can also edit the _CRM Product_, _CRM Product Group_, and _CRM Detail Group_ fields to allow users to select multiple values:

1. Navigate to **Admin > Configuration > Document Fields**.
1. Under _Shared Fields_, select one of the CRM fields.
1. Click **Edit**.
1. Select the **Allow user to select multiple values** checkbox.
1. Click **Save**.

## Reference Constraints

Pre-configured reference constraints are provided on the _CRM Product_ and _CRM Detail Group_ object reference document fields. These constraints allow you to filter _CRM Products_ by _CRM Org_, and _CRM Detail Groups_ by _CRM Products_. These can be modified or removed depending on your use case.

You can also manually configure additional constraints on object reference fields to filter as needed.

### Example: Filtering CRM Org by Country

You can set up dynamic reference constraints to filter _CRM Products_ by _Country_. You can configure this by setting up an additional constraint on the _Country_ object reference field.

To filter _CRM Org_ by _Country_:

  1. Create a custom object join object with a [many-to-many relationship](/en/lr/28740/#many_to_many) between _Country_ and _CRM Org_.
  2. Add **CRM Org** and **Country** as parent objects.
  3. Add the following [dynamic reference constraint](/en/lr/592/#Dynamic_Reference_Constraints) to the **CRM Org** document field: `id IN (SELECT id FROM country_org_join__cr WHERE country__c CONTAINS {{this.country__v}})`.

### Example: Filtering by CRM Org

To set up constraints to filter by _CRM Org_ on the existing _Survey_, _Directory_, and _Content Type_ fields, apply the following VQL expression to each of the [above](/en/lr/46113/#doc_fields) fields:

`crm_org__v CONTAINS {{this.crm_org__v}}`

Note that this will not display existing _Survey_, _Directory_, or _Content Type_ records that do not have the new _CRM Org_ object field populated.

## Enablement

The new objects for this feature, _CRM Product_, _CRM Product Group_, _CRM Org_, and _CRM Detail Group_ are available in all current and new PromoMats and MedComms application Vaults. The document fields for this feature are inactive by default. To use this feature, you must activate these fields and add them to the appropriate document types.

You must perform additional enablement and configuration tasks in CRM to have CRM manage the _Product_, directory, survey, and content type records in Vault in CRM.

 [1]: /wordpress/4884
 [2]: /wordpress/28740#many_to_many
 [3]: /wordpress/592
 [4]: #doc_fields
