Manage Multiple Files Upload in Business Central

Introduction

AL developers can now manage multiple file uploads at once in Business Central, significantly increasing flexibility. The AllowMultipleFiles property lets developers configure the FileUploadAction to accept either a single file or multiple files simultaneously. They can also specify acceptable file types using the AllowedFileExtensions property. This enhancement makes the file upload process more efficient and user-friendly.

Pre-requisites

Business Central (OnPrem/Cloud)

References

Handle Multiple File Uploads

Configuration

Here, for an example, a page extension that extends the “Resource Card” Page, adding a new list part to display uploaded files.

File Upload Action:

AllowMultipleFiles: This property allows users to upload more than one file at a time. In the code example, it is set to true, enabling multiple file selection.
AllowMultipleFiles = true;

AllowedFileExtensions: This property restricts the types of files that can be uploaded. In the code example, it allows only .jpg, .jpeg, and .png files.
AllowedFileExtensions = ‘.jpg’,’.jpeg’, ‘.png’;

OnAction Trigger: Manages file processing:

– Retrieves the highest entry number from the “Uploaded Files New” table.

– For each file:

  1. Creates an in-stream for reading file content.
  2. Inserts file details into the “Uploaded Files New” table.
  3. Displays a message with the file name.

The “Uploaded Files New” table stores the uploaded files’ metadata and content. It includes fields for entry number, resource number, file name, and file content.

List Page for Uploaded Files

The “Uploaded Files List” page displays the uploaded files in a list format, making it easy to view all files associated with a resource.

In the above screenshot you can see the list of images which are uploaded.

Conclusion

This extension enhances the “Resource Card” by integrating a multi-file upload feature, making it easier to manage and access image files related to resources. The AllowMultipleFiles property lets users upload several files at once, while AllowedFileExtensions restricts uploads to specific file types like .jpg, .jpeg, and .png. It’s a simple yet powerful addition that improves usability and efficiency in Business Central.

We hope you found this article useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange