- Home [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
- Getting started
- Manage types
- Global context and isolation
- Manage apps
- Work with external services
- Scripts in widgets
- Web components
- Access permissions
- Getting started with processes
- Getting started with signatures
- Getting started with file previews
- Getting started with the organizational chart
- Getting started with users and groups
-
Getting started with the
Table data type - Use cases
- How to set up custom view of app items
- How to set up dynamic display of fields and widgets with a complex condition
- How to register a document
- How to calculate the number of days between two dates
- How to create a substitution for a user
- How to use pagination and sorting when searching for app items
- API
- Object types
- Data types
- Global constants
- Work with apps
- Web requests
- Access permissions
- Document flow
- Live Chats
- “Code” widget
- Signatures
- Business calendars
- Integration with IP telephony
- Integration with email marketing services
In this article
Getting started with file previews
File viewing and editing on forms and pages are enabled by modules. With their help, you can integrate the necessary functions for users into extension points within the system.
Let’s see how to create a file preview module.
Module configuration
In the Administration / Modules workspace, create a custom module. Read more in the ELMA365 Help Center in the Create a custom module article.
After that, configure the module:
SupportedFileTypes
. Note that this property name is mandatory, as it is checked when searching for modules for the file preview extension point. As values, enter the file formats that the module will display, for example, ppt, pptx, and odp.onInit()
, and the function for checking the display conditions, by defaultcanRender()
. Read more in the ELMA365 Help Center in the System functions in widgets article. For example, you can set a condition so that the widget isn’t displayed if the file format is undefined:async function canRender() { // Retrieve the file format using a custom function const fileType = getFileType(); // If the file format is undefined, the widget template should not be displayed if (!fileType) { return true; } return false; }
link
in the widget’s context. It will store the link to the file and pass it to the template.Go to the Template tab and drag the Code widget onto the form. Insert HTML code into it, which will display a link for downloading the file:
<a href='<%= Context.data.link %>' id='link'>Download link</a>
Here, the link property is accessed through
Context.data
. Edit the script on the Scripts tab so that when the widget is displayed, the link to the file is written to the property:async function canRender() { // Retrieve the file format using a custom function const fileType = getFileType(); // If the file format is undefined, the widget template should not be displayed if (!fileType) { // Custom function that retrieves the download link for the file await renderLink(); return true; } return false; } async function renderLink(): Promise<void> { if(!Context.data.file) { // If the file does not exits, an error message is displayed throw new Error('no file'); } // Retrieve the download link for the file using a system method Context.data.link = await Context.data.file.getDownloadUrl(); }
After this, you will be able to view files in the formats specified in the module settings within the ELMA365 interface.
You can find examples of preview modules in the official ELMA365 documentation in the Custom file viewing and editing module article.
Use cases
Standard widget
The configured module can be used within the standard File preview widget, which defines the preview extension point.
When opening a form or page with the widget added, a search for preview modules is initiated. The first module found suitable for viewing files in the used format is utilized.
There can be multiple modules for one file format in the system. To use a custom preview module, disable unused modules in the Administration / Modules workspace.
Custom widget
To use only the widget created as part of the custom file preview module on a form or page:
view
for view-only,edit
for viewing and editing.