Document preview
A preview of a document from a related widget, right on the form page.
About the documentPreview widget
The widget shows a preview of a document directly on the form, without opening the document and without hovering. It takes the document from a Related documents widget on the same form. It is a virtual widget, not stored in the item, and needs no extra licence.
Adding and linking
On the Widgets tab choose Document preview and drop it into a section. In the settings pick the Related documents widget that supplies the document. The list offers only the Related documents widgets of this form; if there is none, add one first.
Settings
| Option | Property | Meaning | Default |
|---|---|---|---|
| Related documents widget | sourceFieldId | Internal name of the widget that supplies the document. It must exist, otherwise the configuration fails validation. | not selected |
| What to preview | source | Related documents (relatedDocuments) or Current file (currentFile): the file whose properties the form edits. Current file is offered only on a document library and does not need a Related documents widget; the New form shows an empty state. The Open button opens the document in a new tab. | Related documents |
| Height (px) | height | Preview height, 200 to 1200. | 480 |
| Document shown | selection | First, a click in the list switches (firstOrClick) or Always the first (first). | first, click switches |
Runtime behaviour
- Which document: by default the first document of the linked widget, using its sort order and filter. With First, a click in the list switches, clicking another document name in the list switches the preview and highlights the row. Opening the document (preview window) stays available as its own button on each row and as the Open link in the preview.
- File type: Office documents (docx, xlsx, pptx and others) show in the interactive Office Online preview, PDF in the SharePoint PDF viewer, images as an image. For other types the widget says "Preview is not available for this file type" and offers an Open link.
- No document: an empty list and New mode show "No document to preview". A load error (for example missing permission) shows a message instead of the preview.
- Another tab: if the documents list sits on a tab you have not opened yet, the preview asks you to open that tab. Documents are not loaded twice.
- Printing: the preview frame is not printed; the document name and its address are.
- Designer: in the designer preview the widget shows a placeholder frame, or a sample document.
Configuration example (JSON)
{
"internalName": "widget_docpreview",
"customLabel": "Document preview",
"fieldType": "documentPreview",
"colSpan": 12,
"documentPreviewConfig": {
"sourceFieldId": "ProjectDocuments",
"height": 480,
"selection": "firstOrClick"
}
}
Limits and tips
- Only users with permission to the document see the preview; the interactive Office preview needs Office Online to be allowed in the tenant.
- The widget restricts the embedded frame so it cannot redirect the form; links inside the document open in a new tab.