# Configure Dynamic Safety Views

_Dynamic Views_ are a type of <a href="/en/gr/752978/">safety view</a> that contain object fields commonly used in reporting. Once you associate these views with a _Principal View_, users can create their own custom reports to analyze Safety data without you configuring an appropriate safety view for every ad-hoc report. 

To use dynamic fields on _Workbench Reports_, you must: 
* [Configure a _Dynamic View_][1]
* [Configure a _Workbench View Dynamic Join_][2]
* [Configure a _Workbench View Column Dependency_][3]

## Prerequisite

Before performing configuration for _Dynamic Views_, you must insert the _Workbench View Dynamic Join_ <a href="/en/gr/26387/#how-to-add-sections">related object section</a> after the _Workbench View Columns_ section for the _Workbench View_ object _Principal View Detail Page Layout_.

## Configure Dynamic Views {#configure-dynamic-views}

To configure a _Dynamic View_:
1. <a href="/en/gr/752978/#create-and-access-safety-views">Create a _Workbench View_</a> with a safety view type of _Dynamic View_. 
2. In the _SQL Editor_ section, <a href="/en/gr/752978/#sql-editor">enter SQL</a> according to your business needs.
3. Select **Save**.
4. <a href="/en/gr/752978/#workbench-view-columns">Create _Workbench View Columns_</a> to specify which object fields users can add to the _Workbench Report_ layout for data analysis. 
5. Optional: <a href="/en/gr/752978/#run-preview">Preview</a> the data.

<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 cannot add dependent views, <em>Workbench View Objects</em>, or <em>Workbench View Parameters</em> to <em>Dynamic Views</em>.</p>
    </div>
  </div>
</div>



## Configure Workbench View Dynamic Joins {#configure-dynamic-joins}

Associate a _Dynamic View_ with a _Principal View_ by configuring a _Workbench View Dynamic Join_:
1. Navigate to **Business Admin > Objects > Workbench View**.
2. Select a _Principal View_ and expand the **Dynamic Views Join** section.
3. Select **Create**.
4. On the _Create Workbench View Dynamic Join_ page, complete the applicable [fields][4].
5. Select **Save**.

You can associate the same _Dynamic View_ with different _Principal Views_. You can also associate up to 15 different _Dynamic Views_ with a _Principal View_.

### Workbench View Dynamic Join Fields {#dynamic-join-fields}

The following fields may be available:

<table>
    <thead>
        <tr>
            <th>Fields</th>
            <th>Descriptions</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><em>Dynamic View</em></td>
            <td><p>The <em>Dynamic View</em> in association with the <em>Principal View</em>.</p>
                <p>Select an option from the drop-down or select the <strong>Advanced Search</strong> (<img class="inline" src="https://platform.veevavault.help/assets/images/saf-binoculars-icon.png" alt="binoculars-icon" style="" />) icon to use filters and refine your search.</p>
            </td>
        </tr>
        <tr>
            <td><em>Join Condition 1 Foreign Key</em></td>
            <td><p>Any view column on the <em>Dynamic View</em>. This is usually an <em>Object</em> view column type that references the <em>Principal View</em>. For example, the foreign key field on the <em>Dynamic View</em> is the field containing the <em>Case</em> for a <em>Principal View</em> that is a <em>Case</em>-level line listing.</p>
                <p>Select an option from the drop-down or select the <strong>Advanced Search</strong> icon to use filters and refine your search.</p>
            </td>
        </tr>
        <tr>
            <td><em>Join Condition 1 Primary Key</em></td>
            <td><p>Any view column on the <em>Principal View</em>. This is usually the unique identifier for every record returned by the view.</p>
                <p>Select an option from the drop-down or select the <strong>Advanced Search</strong> icon to use filters and refine your search.</p>
            </td>
        </tr>
        <tr>
            <td><em>Join Condition 2 Foreign Key</em></td>
            <td>Optionally, select another view column of the <em>Dynamic View</em> from the drop-down or select the <strong>Advanced Search</strong> icon to use filters and refine your search.</td>
        </tr>
        <tr>
            <td><em>Join Condition 2 Primary Key</em></td>
            <td>Optionally, select another view column of the <em>Principal View</em> from the drop-down or select the <strong>Advanced Search</strong> icon to use filters and refine your search.</td>
        </tr>
        <tr>
            <td><em>Principal View</em></td>
            <td>The <em>Principal View</em> in association with the <em>Dynamic View</em>.</td>
        </tr>
    </tbody>
</table>

A join condition equates the foreign key and primary key. One join condition is required. If provided, Vault considers both join conditions when associating a _Dynamic View's_ records with a _Principal View's_ records.

<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>: Vault does not support duplicate view column API names in the <em>Dynamic View</em> or between the <em>Principal View</em> and <em>Dynamic View</em>. </p>
    </div>
  </div>
</div>



## Configure Workbench View Column Dependencies {#configure-view-column-dependencies}

When a _Workbench Report_, _Workbench Dashboard_, or _Workbench Report Set_ runs, Vault executes the SQL configured in the associated safety view to generate results. _Workbench View Column Dependencies_ allow custom safety views to reference a _Dynamic View's_ view columns in the SQL. To create a _Workbench View Column Dependency_: 
1. Navigate to **Business Admin > Objects > Workbench View Column Dependencies**. 
2. Select **Create**. 
3. Complete the following information: 
    * **Dependent View**: Select the _Dynamic View_ with the desired view column from the drop-down or select the **Advanced Search** icon to use filters and refine your search.
    * **Dependent View Column**: Select a _Dynamic View_ view column from the drop-down or select the **Advanced Search** icon to use filters and refine your search.
    * **Workbench View**: Select the safety view in which you want to reference the _Dynamic View's_ view column from the drop-down or select the **Advanced Search** icon to use filters and refine your search.
4. Select **Save** or **Save + Create** to save the record and create another.

When you delete or copy the referenced safety view, Vault also deletes or copies the _Workbench View Column Dependency_. 

### How Dynamic Views Work with Safety Views {#how-dynamic-views-work}

This section describes an example of how you might use a _Dynamic View_ and configure a _Workbench View Column Dependency_. In this scenario, a _Principal View_, which is a _Case_ line listing, leverages a _Dynamic View_ that provides _Case Contact_ information. You want to create a _Workbench View_ that is dependent on this _Principal View_ to return serious _Case_ counts in each country. To do this, you could configure a _Workbench View Column Dependency_ with the following values:
* **Dependent View**: [The _Dynamic View_]
* **Dependent View Column**: [The _Country_ view column from the _Dynamic View_]
* **Workbench View**: [The _Workbench View_]

You can then write SQL query to group the _Workbench View_ data by _Country_.

[1]: #configure-dynamic-views
[2]: #configure-dynamic-joins
[3]: #configure-view-column-dependencies
[4]: #dynamic-join-fields