Home > Canvas Apps > Canvas App | Attachments | File Size and File Type validations

Canvas App | Attachments | File Size and File Type validations

Have you ever got “File to large” error while using Attachments control, something as below.

In this short article lets understand how to configure the size limits and also File Type validation

Steps to set the ‘MaxAttachmentSize’ for the ‘Attachments’ control:

MaxAttachmentSize  property limits the maximum allowed file size in MB of each new attachment. So we need to set this property as shown below.

  • Open the Canvas App and select the Attachments card.
  • From the Properties set the ‘Maximum attachment size (in MB)’ to desired limit.
  • Save and Publish

Validate attached file by file type:

  • If you need your Attachments control to accepts certain file type(s), add validation logic on OnAddFile event of Attachments control.
  • Formula to validate single file type (i.e., .msapp):
If(
    Not(
        EndsWith(
            First(Self.Attachments).Name,
            ".msapp"
        )
    ),
    Notify(
        "Only a MSAPP File (.msapp) is allowed.",
        NotificationType.Error
    );
    // Clear the attached file
    Reset(Self)
)
  • Formula to validate multiple file types (i.e., msapp and zip):
If(
    Not(
        EndsWith(
            First(Self.Attachments).Name,
            ".msapp"
        )
    ) And Not(
        EndsWith(
            First(Self.Attachments).Name,
            ".zip"
        )
    ),
    Notify(
        "Either a MSAPP File (.msapp) or Zip File (.zip) is allowed.",
        NotificationType.Error
    );
    // Clear the attached file
    Reset(Self)
)

Notes:

  • The attachment control has these limitations:
    • The attachment control only supports lists and Dataverse tables as the data sources.
    • Attachments control on a web browser lets you select multiple files, However, when using attachments control on Power Apps Mobile, you can only add files one at a time.
  • MaxAttachments  property limits the maximum number of files the control will accept.

🙂

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: