# How To: View Document Versions in the Documents LWC

The **View Document Versions** feature in the Documents (S-Docs) Lightning Web Component allows users to **view and manage version history** for generated documents directly from a Lightning record page.

Each time a document is refreshed or updated using supported actions, S-Docs automatically creates a **new version** of the document while preserving earlier versions for reference, comparison, and audit purposes.

***

### Enabling Document Versioning

To allow users to view document version history, versioning must be enabled in the component configuration.

**To enable document versions:**

1. Open **Lightning App Builder**.
2. Edit the record page.
3. Select the **Documents (S-Docs)** component.
4. Enable **Show Versions**.
5. Click **Save** and activate the page.

Once enabled, users will see a **Versions** option next to generated documents in the Documents LWC.

***

### How Document Versions Are Created

Document versions are automatically created when:

* A document’s data is refreshed using **Refresh Data**
* A document is updated using the **Live Edit** feature (if enabled)

Each version represents a snapshot of the document at that point in time.

***

### Viewing Document Versions

Once versioning is enabled, users can view previous versions directly from the record page.

**To view document versions:**

1. Navigate to the record page.
2. Locate the document in the **Documents (S-Docs)** component.
3. Click the **Versions** option for the document.
4. A list of available versions is displayed on a pop up screen.
5. Select a version to view or download it.

The most recent version is shown as the active version by default.

***

### Benefits of Document Versioning

Viewing document versions allows users to:

* Track changes made to documents over time
* Compare previous and updated document content
* Restore or reference earlier versions if needed
* Maintain an audit trail for compliance and approvals

{% hint style="info" %}
**Considerations**

* Document versions are only visible when **Show Versions** is enabled.
* New versions are created by **Refresh Data** and **Live Edit** actions.
* Versioning does not apply to HTML email templates.
* Runtime Prompts and Job Splitters are not compatible with document versioning.
* Version history is associated with the same Salesforce record.
  {% endhint %}

***

### Recommended Configuration

For optimal usage:

* Enable **Show Versions** alongside **Show Refresh**
* Place the **Documents (S-Docs)** LWC below the **Generate Documents (S-Docs)** LWC
* Enable versioning for records where document accuracy and traceability are important

This configuration allows users to generate, update, review, and track documents efficiently without leaving the record page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/automation-and-document-lifecycle/workflows/view-document-versions-in-the-documents-lwc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
