# Generate Aggregate Report Documents from Reports

Learn how to automatically generate Aggregate Report documents from reports in your Vault.

<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>: Depending on your Admin’s configuration, object, field, and section labels, lifecycle states, and workflows may differ from the general information on this page. Refer to your organization’s business processes for guidance.</p>
    </div>
  </div>
</div>



## About Generating Aggregate Report Documents from Vault Reports

Vault SafetyDocs supports automatically generating aggregate report documents from Vault reports and linking them to related Aggregate Report Sections. 

You can set up reports in your Vault to gather data such as custom interval line listings and custom tabulations, and then link them to Aggregate Report Sections where this data is needed. When you choose to generate a document from one of these reports, the system creates a document with data from the report and links it to the associated Aggregate Report Section. This process eliminates the need for manually running reports and uploading updated documents every time any information changes.

The following sections provide more details about the document generation process.

### Prerequisite

Your Admin must <a href="/en/lr/680651/">enable Aggregate Report Management</a>.

## Link a Report to an Aggregate Report Section

To automatically generate a document from a report, you must link the report to an Aggregate Report Section by completing the following steps:

1. Go to the **Aggregate Report** record on which you want to link a report to a Section.
2. Create Aggregate Report Sections. 
    * If you are <a href="/en/lr/680414/#automatically-generate-sections">automatically generating Sections</a> using a template and your Admin has completed the fields in the table below on the corresponding Template Item, the system automatically creates a **Vault Report** type Section and links it to the respective report. 
    * If you are <a href="/en/lr/680414/#manually-create-sections">manually creating Sections</a>, in the **Create Aggregate Report Section** dialog, select **Vault Report**.
3. In the **Details** section, complete the following fields and select **Save**:

<table>
    <thead>
        <tr>
            <th>Field</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Source Report</td>
            <td>Select the appropriate report. You can select <strong>More search options</strong> to open the <em>Search: Source Report</em> dialog to filter search results.</td>
        </tr>
        <tr>
            <td>Source Report Prompt</td>
            <td>If your report has additional parameters, this is the string of characters identifying the specific parameter related to the document you want to generate. 
            <p>From the report's URL, copy the string of characters after the question mark (<code>?</code>) until the end of the URL and paste it into this field. See the image below for reference.</p></td>
        </tr>
        <tr>
            <td>Report Format</td>
            <td>Select the format in which you want the document to be generated. The available options include the following:
                <ul>
                    <li><strong>PDF</strong></li>
                    <li><strong>Excel</strong></li>
                    <li><strong>Excel Template</strong> (Your report must have an Excel Template configured to use this option)</li>
                </ul></td>
        </tr>
    </tbody>
</table>

<a href="https://platform.veevavault.help/assets/images/saf-source-report-prompt.png" data-lightbox="saf-source-report-prompt.png" data-title="Source Report Prompt in Report URL" data-alt="Source Report Prompt in Report URL">
  <img class="docimage" src="https://platform.veevavault.help/assets/images/saf-source-report-prompt.png" alt="Source Report Prompt in Report URL" style=""  />
</a>

### Tokens for Source Report Prompts

If the report from which you are generating documents uses filters, you can use tokens in the **Source Report Prompt** field to represent the related field values. Every time you generate a document from this linked report, the system replaces the token with the most updated value of the field it represents. This process eliminates the need for manually updating the source report prompt every time some information changes. 

Vault SafetyDocs supports the following dynamic tokens for source report prompts:

<table>
    <thead>
        <tr>
            <th>Token</th>
            <th>Source Field</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>${AggregateReport}</td>
            <td><strong>Aggregate Report</strong></td>
        </tr>
        <tr>
            <td>${ProductFamily}</td>
            <td><strong>Product Family</strong></td>
        </tr>
        <tr>
            <td>${DataPeriodStart}</td>
            <td><strong>Data Period Start</strong></td>
        </tr>
        <tr>
            <td>${DataPeriodEnd}</td>
            <td><strong>Data Period End</strong></td>
        </tr>
        <tr>
            <td>${HealthAuthority}</td>
            <td><strong>Health Authority</strong>
                <p>This field applies to Local Sections only.</p></td>
        </tr>
        <tr>
            <td>${ApplicableMarket}</td>
            <td><strong>Applicable Market</strong>
                <p>This field applies to Local Sections only.</p></td>
        </tr>
    </tbody>
</table>

## Generate Documents

Once the report has been linked to the Aggregate Report Section, go to the **All Actions** menu of that **Section** record and select **Generate Vault Report Document**.

**Result**

This action initiates the following:

* The system uses the values entered in the related fields to identify which report to run.
* The associated report is run and a document is generated in your Vault library with data from the report.
* The document is linked back to the Aggregate Report Section in the **Report Document** field.

During the authoring process, if your Aggregate Report Sections have not reached the **Complete** state, you can initiate the **Generate Vault Report Document** action again to update this document. When the action is re-initiated, the system runs the associated report again and upversions the document with the updated details.