---
title: Preview SSRS report
summary: Loads a parameterized SSRS report through the SharePoint report execution SOAP service and renders it to the requested output format.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-30
library: SAIF.Services.Printing
reference_type: package
operation_id: OP-PRT-08
trigger: Caller invokes clsRSPrint.PreviewDocument after configuring ReportPath, Format, and optional parameters
---

# Preview SSRS report

`clsRSPrint.PreviewDocument` renders an SSRS report through the `SharepointReporting.ReportExecutionService` SOAP endpoint. It is a separate, standalone code path from the xPression preview/print/distribute workflow in `clsPrint`; it does not share state or transport with xPression at all. `clsRSPrint` supports preview and render only — its `DistributeDocument` method always throws.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-PRT-08 |
| **Trigger** | Caller sets `ReportPath`, optionally `Format`/`ImageFormat`, optionally queues parameters via `AddParameter`, then invokes `PreviewDocument()` |
| **Inputs** | Report path; output format (`CSV`, `Excel`, `HTML`, `Image`, `PDF`, `Word`, `XML`); image format when applicable; a name/value parameter collection |
| **Outputs** | Rendered report byte array in the selected format |
| **Primary components** | `clsRSPrint.PreviewDocument`, `clsRSPrint.BuildParameters`, `clsRSPrint.AddParameter` |
| **Entry point** | `Services\SAIF.Services.Printing\clsRSPrint.vb` |

## Steps

1. The caller sets `ReportPath` to the target SSRS report.
2. The caller optionally sets `Format` (defaults to `PDF`, mapping to extension `pdf`) or `ImageFormat` (defaults to `JPEG`) through the respective property setters, which translate the enum value into the internal `m_Format`/`m_Extension` or `m_ImageFormat` strings used by the render call.
3. The caller optionally queues report parameters with one or more `AddParameter(name, value)` calls, or clears them with `ClearParameters()`.
4. `PreviewDocument` assigns `System.Net.CredentialCache.DefaultCredentials` to the generated SSRS proxy's `Credentials` property.
5. `PreviewDocument` calls `m_RS.LoadReport2(ReportPath, HistoryID)` to load the target report.
   - `HistoryID` is deliberately left uninitialized rather than assigned an empty string, because initializing it causes the call to fail with an invalid `SnapshotId` error.*
6. If the parameter collection has entries, `PreviewDocument` allocates a `ParameterValue` array sized to the collection, calls `BuildParameters` to copy each name/value pair into it, and submits the array through `m_RS.SetExecutionParameters`.
7. `PreviewDocument` calls `m_RS.Render2` with the configured format, extension, and `PageCountMode.Actual`, and returns the resulting byte array.

## Process flow

The following diagram visualizes the SSRS preview sequence.

```mermaid
flowchart TD
	Start([Caller sets ReportPath, Format,<br>optional parameters]) --> Cred[Assign default credentials]
	Cred --> Load[Call LoadReport2]
	Load --> HasParams{Parameters queued?}
	HasParams -->|Yes| Build[BuildParameters and<br>SetExecutionParameters]
	HasParams -->|No| Render
	Build --> Render[Call Render2]
	Render --> End([Return rendered bytes])
```

## Failure and edge-case behavior

- `DistributeDocument` on `clsRSPrint` always throws `NotImplementedException` ([BR-006](../business-rules.md#br-006-ssrs-distribution-is-not-implemented)); consumers needing distribution must use the xPression-based [Distribute document (synchronous or asynchronous)](distribute-document.md) operation instead.
- `PreviewDocument` does not catch exceptions from `LoadReport2`, `SetExecutionParameters`, or `Render2`; any SOAP fault propagates directly to the caller.*
- `HistoryID` is passed uninitialized to `LoadReport2` by design (per the inline source comment); explicitly initializing it is documented in source as causing the call to fail.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `Services\SAIF.Services.Printing\clsRSPrint.vb`
