Shotgun Studio How to Upload Without Sending Out Message
Configure File Upload and Download
Last modified: March 15, 2022
1 Introduction
This how-to explains how you lot tin enable your terminate-users to attach and download files, such as PDF files or Microsoft Word documents. They will be able to attach files from different devices: phone, tablet, or desktop; as well equally download attached files from a list.
This how-to will teach you how to do the following:
- Create file entities
- Create a page with a form that allows your end-users to upload files
- Display attached files in a listing
- Let your end-users to download files
The how-to describes the following utilize case:
Your company has an app where visitor's IT department keeps rails of assets assigned to employees. Yous have the Employee Profile folio with a class (a data view) that has such details equally employee'due south name, section, their electronic mail, phone, title, and assets assigned to them (for case, a mobile phone or laptop). This data is filled in and updated by IT administrators:
The domain model looks the following way:
You would like to add a new functionality: It administrators should be able to attach files to an employee profile, for example, to attach telephone or laptop policy signed by the employee.
Yous also would like to enable Information technology administrators to download the fastened file from a listing of files.
2 Prerequisites
Earlier starting this how-to, make certain you have completed the following prerequisites:
- Familiarize yourself with page terms and how to perform bones functions on pages. For more than information, see Pages.
- Familiarize yourself with the domain model terms and learn how to perform basic functions. For more information, see Domain Model.
iii Creating a File Entity
First of all, to be able to attach and/or download files you need to add together a special type of entity to your domain model: a file entity. Practise the following:
-
Open your domain model and open up the Toolbox tab.
-
Select the File Entity and drag and drop information technology to your domain model.
-
In the Create New File Entity dialog box, gear up Proper name to Document and click Create.
-
Now you need to create an association from the File entity to the Employee entity. Do 1 of the following:
-
Hover over the File entity, click the dot icon, and drag the dot to the Employee entity:
-
Select the File entity, click the arrow icon, and select Employee equally a 2d entity for the association:
-
Good task! Yous accept created the file entity and an association from information technology to the Employee entity:
4 Adding a File Director
A File Manager is a widget that allows your end-users to attach and/or download files. Yet, it can only function inside a data container (a listing view or information view), and the listing view or data view can merely have a file entity as its information source. If you just drag and driblet the file director to your employee contour form, it will non work correctly, because your current data view has the Employee entity equally its data source, and you need the information source to be a file entity, which is in this case the Document entity:
To solve this, you lot can add a button which will open a pop-up page where your stop-users (Information technology administrators) tin upload images. This page volition be continued to your current report form over the Document_Employee association and will upload files that are associated to this specific report.
Follow the steps below:
-
Open the Employee Profile page where IT administrators create and edit information on employees and assets assigned to them.
-
Open the Toolbox and search for the Create Object button.
-
Drag and drop the push button above Salvage and Cancel buttons:
-
Open push button properties and exercise the post-obit:
-
Select the Caption property and rename it from New to Attach File.
-
Click the Icon property.
-
In the Select icon dialog box, search for the file icon, and click Select.
-
Click the Mode property and alter it from Default to Success. Afterward your changes, the button will look the post-obit fashion:
-
Click the Entity property.
-
In the Select Entity dialog box, choose the Document entity over Document_Employee clan and click Select:
-
Click the Folio property.
-
In the Select Page dialog box that opens, click the plus icon in the acme right corner to add a new page.
-
In the Create new page dialog box, do the following:
-
Fix the Championship to Attach File.
-
Ready the Layout to PopupLayout.
-
The Pre-fill page contents based on the Certificate entity pick is on, so the page template (Forms) is selected automatically for you. Choose Course Vertical and click Create.
-
A new popular-upwardly page with a preconfigured form (a data view) is created:
-
As you only demand your end-users to adhere files on this folio, delete Name and Size text boxes from the data view.
-
Open the Toolbox, search for a File Uploader, drag and driblet it inside the data view.
-
-
You lot take created a pop-upwardly folio that will let IT administrators to adhere files to the employee profile form:
5 Downloading Files
After your end-users attach the files, it would exist nice to display files in a listing and give users an opportunity to download attached files if needed. To practice so, you need to add a list:
-
Open the Employee_Profile folio.
-
In the Building Blocks, search for Listing four and drag and driblet it under the Attach File push (brand sure yous drop it inside the data view, this mode yous will be able to listing only files associated with a selected employee instead of all files that were attached to any employee profile). A list view with widgets inside it is added to your page:
-
Select the list view, open its backdrop, and do the following:
-
Click the Entity holding.
-
In the Select Entity dialog box, choose the Document entity over Document_Employee association and click Select:
-
-
Delete the image and a column information technology is placed in from the list:
-
Delete a subtitle in the list proverb Hither you can put a subtitle.
-
Select the Name text in the listing view, open its properties, and exercise the post-obit:
-
In the Content property, delete the Name text and click Add together attribute.
-
In the Select Aspect dialog box, choose the Name aspect and click Select to brandish the proper name of the attached file.
-
-
Delete the Details push button in the list view.
-
Open the Toolbox and search for a File Downloader, elevate and drop it to the cavalcade where the Details push was placed.
-
Open the File Downloader (File Manager) properties > Characterization belongings and delete the File text from it.
Great chore! Now you have the listing that shows attached files and your users can download files from this listing:
Congratulations! You take configured the class that allows IT administrators to adhere files and displays these files in the list.
Preview your app to test how the file uploading and downloading works:
You can also configure a push to adhere images instead of files. For more information, see How to Enable End-Users to Attach Images.
Source: https://docs.mendix.com/studio-how-to/pages-how-to-attach-files/
Postar um comentário for "Shotgun Studio How to Upload Without Sending Out Message"