Power Community

Power Community

Show total size of all attachments on a record

image

I posted a blog a little while back on how to show the size of an attachment or uploaded file to the user. What if you want to see the total size of all attachments ? 
Firstly, insert a gallery (you can hide it after the settings below are made and I will call galAttach in the code below) with the Items

YourAttachmentControlName.Attachments

 Now put an Image control in the Gallery (called imAttach below) with the Image

ThisItem.Value

You will need to trigger the next piece, so a button with “Size” or similar below the attachment control will do the job.

ForAll(
   galAttach.AllItems,
   Collect(
      colSize,
      {
         ImSize: 
         (Len(
            JSON(
               imAttach.Image,
               JSONFormat.IncludeBinaryData
            )
         ) - 814) / 137000
      }
   )
);
UpdateContext(
   {
      varSize: 
      Sum(
         colSize,
         ImSize
      )
   }
)

A collection is being made here containing a calculation of the size of the JSON text conversion of each image, then a Variable is being set to the total of all of these values, so you can then have a Label with

Total Attachment size: & " varSize & " Mb"

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

5 Benefits of In-App Notifications for Microsoft Dynamics 365 CRM users

For a successful sales process, you need to stay up-to-date with crucial sales information like deal closures, opportunities won,...

More Articles Like This

- Advertisement -spot_img