# Creating & Deleting Document Relationships Using Vault Loader

<a href="/en/gr/26597/">Vault Loader</a> allows you to bulk create and delete document relationships in your Vault. Note that you cannot create or delete standard relationship types. Examples of standard relationship types include _Based On_, _Original Source_, _and Attachments_.

## How to Load Document Relationships

Before loading document relationships, [prepare the CSV input file][2] containing field names and values.

To create or update document relationships:

  1. In the left panel of the **Loader** tab, click **Load**.
  2. For the **CSV File**, click **Choose** and select the CSV input file.
  3. In the **Entity Type** picklist, select **Documents Relationships**.
  4. In the **Action Type** picklist, select **Create** or **Delete**.
  5. Optional: Select the <a href="/en/gr/54028/">Document Migration Mode</a> checkbox.
  6. In the **Key Field** drop-down, select the **ID** field. This option is only required for the _Delete_ action.
  7. Click **Start Load**.

Before processing the request, Vault [validates the selected CSV file][3]. If the file is valid, Vault begins processing the request. When finished, you'll receive a <a href="/en/gr/26597/#loader-notifications-outputs">Vault notification and email</a> with request details and CSV output files.

## Preparing the CSV Input File {#preparing}

The fields you include in your CSV  will depend on your **Create** or **Delete** action. If you aren't sure where to begin, see the [example CSV inputs][5] below.

<table class="wbord">
  <tr>
    <td>
      <strong>Column Header</strong>
    </td>
    <td>
      <strong>Example Value</strong>
    </td>
    <td>
      <strong>Notes</strong>
    </td>
  </tr>
  <tr>
    <td>
      id
    </td>
    <td>
      23
    </td>
    <td>
      The id of the document relationship. This is required for deleting relationships.
    </td>
  </tr>
  <tr>
    <td>
      source_doc_id__v
    </td>
    <td>
      17
    </td>
    <td>
      Required for creating document relationships between the source and target documents.
    </td>
  </tr>
  <tr>
    <td>
      source_major_version__v
    </td>
    <td>
      2
    </td>
    <td>
      The major version number of the source document. This only applies when the target document is bound to a specific version of the source document.
    </td>
  </tr>
  <tr>
    <td>
      source_minor_version__v
    </td>
    <td>
      1
    </td>
    <td>
      The minor version number of the source document. This only applies when the target document is bound to a specific version of the source document.
    </td>
  </tr>
  <tr>
    <td>
      target_doc_id__v
    </td>
    <td>
      22
    </td>
    <td>
      The document id field of the target document which is bound to the source document. This is required for creating document relationships between the source and target documents.
    </td>
  </tr>
  <tr class="alt-table-row">
    <td>
      target_major_version__v
    </td>
    <td>
      1
    </td>
    <td>
      The major version number of the target document. This only applies when the source document is bound to a specific version of the target document.
    </td>
  </tr>
  <tr class="alt-table-row">
    <td>
      target_minor_version__v
    </td>
    <td>
      3
    </td>
    <td>
      The minor version number of the target document. This only applies when the source document is bound to a specific version of the target document.
    </td>
  </tr>
  <tr>
    <td>
      relationship_type__v
    </td>
    <td>
      supporting_documents__c
    </td>
    <td>
      The relationship type (supporting documents, related claims, related materials, etc.). This action only supports <a href="#supported_relationships">custom relationships</a>.
    </td>
  </tr>
</table>

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: You can use the <code class="language-plaintext highlighter-rouge">source__vr.external_id__v</code> and <code class="language-plaintext highlighter-rouge">target__vr.external_id__v</code> fields instead of the <code class="language-plaintext highlighter-rouge">source_doc_id__v</code> and <code class="language-plaintext highlighter-rouge">target_doc_id__v</code> fields when creating a document relationship.</p>
    </div>
  </div>
</div>



### <span id="supported_relationship_types"><a id="supported_relationships"></a>Supported Relationship Types</span>

This action supports the following custom relationship types:

  * Claims
  * Components
  * Licence Files
  * Patient Labeling
  * Product Labeling
  * Related Documents
  * Related Materials
  * Supporting Documents

Note that your organization may have worked with Veeva Services to create additional custom relationship types for your Vault.

<a id="Samples"></a>See example inputs:

  * <a class="external-link " href="https://developer.veevavault.com/docs/sample-files/vault-create-doc-relationship-sample-csv-input.csv" target="_blank" rel="noopener">Create document relationships<i class="fa fa-external-link" aria-hidden="true"></i></a>
  * <a class="external-link " href="https://developer.veevavault.com/docs/sample-files/vault-create-source-version-specific-relationship-sample-csv-input.csv" target="_blank" rel="noopener">Create source version-specific relationships<i class="fa fa-external-link" aria-hidden="true"></i></a>
  * <a class="external-link " href="https://developer.veevavault.com/docs/sample-files/vault-create-target-version-specific-relationship-sample-csv-input.csv" target="_blank" rel="noopener">Create target version-specific relationships<i class="fa fa-external-link" aria-hidden="true"></i></a>

## File Validation {#file_validation}

Before beginning the Vault Loader job to create or delete document relationships, Vault checks that the selected CSV file meets certain criteria:

  * Is not empty
  * Does not contain empty columns
  * Includes a valid header row (Invalid header rows are those with no columns that match to metadata for the records you're loading.)

If your file is not valid, Vault displays a notification, stops the process, and allows you to select a new CSV file. If some of the header columns do not match metadata for your Vault, the notification will allow you to stop the load or ignore those columns and proceed.

 [2]: #preparing
 [3]: #file_validation
 [5]: #Samples
