Klevr Product Documentation logo

Azure Blob Attachments

This feature allows the ability to configure an attachment section on a Dynamics form that will allows the user to select and upload or drag and drop 1 or...

Feature Overview

This feature allows the ability to configure an attachment section on a Dynamics form that will allows the user to select and upload or drag and drop 1 or more files. The files will be stored in Azure Blob Storage (connection configured in the configuration file) and a custom activity of type klevr_azureattachment will be created for each file uploaded. The activity is automatically associated to the current record displayed, and the portal created by is set to the current logged in user.

Improvements include the ability to optionally request a file description and/or a file type per uploaded file. The file description will be saved in the azure attachment description field, and the file type is a lookup to an azure attachment type entity. You can specify your own file types in here as per your customer's requirements. You also need to configure a portal security entry to allow users to see the file types. This allows you control file types per role, or manage changing file types by using a status filter.

On the page configuration for the attachment, you can specify a further filter for the current page, thus allowing you to have file types matching with specific entities. You can use the tags feature on the file type to tag file types per entity and add a filter on the tag on the Umbraco page.

Assumptions

None identified

Dependencies

The following are dependencies for this feature:

  1. You have the latest klevr CE solutions installed (including klevr forms).
  2. You have a storage account for use for these attachments. Highly recommended to use a different storage account from the media file container, which is used for page content media.

Design Details

CE Activity entity, CE File Type entity, Blob storage, front end controls, Umbraco configuration

Security Considerations

  1. The portal user requires create, read, write and delete to the azure attachment record to be able to perform these functions on the record or the associated blob file. The portal user also need read access to the file type entity if you wish to use it.
  2. The blob storage should not be marked as public. The link to the file in blob storage should not be exposed on the portal. The portal will proxy the download and upload of files to blob.
  3. There is currently no malware scanning configured. You should either configure Microsoft Defender for Cloud or implement your own solution for malware scanning your blob storage to ensure you are not allowing the up or download of malware between portal users or back office staff.
  4. Ideally portal attachments must only be performed by logged in members. Although it can be configured for anonymous users, there is no extra control or checks for bad actors in this scenario. If you need it available anonymously, you will need to implement extra measures like captchas and the like.

Usage

To configure attachments for an entity follow these steps:

1
Enable activities

Ensure the primary entity you want to attach files to has activities enabled.

2
Set up file types (optional)

If you want to use file types, ensure you have file type records in Dynamics and entity permissions in the portal.

3
Add the Blob Attachments content item

On the Dynamics Form content page for the entity in the Umbraco Back Office, add a new content item of type Blob Attachments.

4
Configure the section parameters

Configure the parameters on the section.

5
Add a subgrid

Directly underneath it, add a subgrid for Azure Attachments.

6
Style the subgrid

For the best look and feel, leave the subgrid label blank, and select the "hide action bar" toggle on the subgrid parameters.

7
Configure the subgrid view

Configure the subgrid to show the details from the azure attachment record as you desire. Note that the subject is populated with the file name, and you must not show the blob url or blob id fields. You can show the created by portal user field if you wish. If you are using file types, you need to include this in the view for the built in validation to work.

8
Optionally render as cards

You can optionally render the list as cards too.

9
Add a download button (optional)

If you want to allow download, add a download button to the list. (suggestion: use the pi-download icon). In the javascript function, call this.DownloadAttachment()

10
Add a delete button (optional)

If you want to allow removal, add a delete button to the list (pi-times). invoke the "this.Delete()" function. Ensure you have delete permissions configured on the azure attachment entity.

11
Filter the buttons (optional)

You can specify filters for the buttons to filter for example only allow delete on files uploaded by the current user.

12
Do not add a create page

Do not specify a create page for attachments from the subgrid. They are created by the Blob Attachment control. You can specify a details page if you want users to edit other fields on the attachment record, like the description.

13
Add a download button to the details page (optional)

If you have a details page, you can also add a download button to it by specifying "this.DownloadAttachment()" in the javascript.

14
Configure the Blob Attachment Configuration

On the Blob Attachment Configuration in Umbraco, you can specify the following:

  • "Accept" mime types allowed.
  • Max file size (in bytes) you want to allow. Azure blob storage can deal with extremely large files, but you can limit it if need be
  • File limit per record. This will attempt to ensure the user do not upload too many files. using multiple windows this can be bypassed.
  • Auto Upload: This only applies if you are not requesting a description or file type to be entered. This will cause the file to be uploaded and added to the list as soon as it is selected or dropped.
  • Description Label. Leave blank if you do not want the user to enter a description, otherwise specify a value for the description field label.
  • Description is Mandatory: Allows the user to submit a file with a blank description, or force them to enter one.
  • File Type label: Leave blank if you do not want to use file types, otherwise specify a label. File types will be rendered as a picklist for the user to select.
  • File Type is Mandatory: Allows the user to upload without specifying a file type, or forcing them to select one.
  • File Type Filter: the "<Condition ...>" or "<filter ....>" part of the FetchXML for a Azure File Type record. For instance you could use tags to identify which entity a specific file type should apply to, and then you can specify a filter here to only list those file types on this page. E.g.: <condition attribute="klevr_tags" operator="like" value="%Portal%" />
  • Validation Function: Leave blank for no validation. Specify ValidateAttachments with 3+ parameters to use the built in validation. Min, max, and any number of file type values in quotes that need to be present, e.g. ValidateAttachments(1, 5, "Personal Info", "Application"); Alternatively, specify the name of your custom javascript function (no brackets) to write your own validation.

Last updated on