How to download Notes from Power Apps Canvas Apps?

Follow Debajit’s Power Apps & Dynamics 365 Blog on WordPress.com

This one is a really cool requirement I came across today. I had this requirement, I implemented it and I can’t wait to share it with my readers.

So what am I going to cover here? In this blog I am going to cover the following requirements.

  • How to download notes in Dynamics 365/ CDS from a Canvas app?
  • How can you download a file in Canvas app if you have the base64 content?
  • How can I download the email attachments of CDS/ Dynamics 365 from a Canvas app?
  • How can you display notes of record in CDS in a canvas app?
  • How to enable a PCF control to use inside a Canvas app?

So let’s start with the scenario here. For this demo, I have create a simple canvas app which shows a list of accounts and when you select an account I display the notes associated with the account.

Once I select an account, it displays the notes related to the account.

But how do I display the Notes related to the account I select. Quite easy actually. All you need is another Gallery control and set it’s Items property to the Notes collection for the selected account. Precisely as shown in the screenshot below.

Now coming to the Notes design. I have a download Icon to download the file for each note.

I set the Visible property of the Icon to the following formula. The Icon only displays if the Note has a document.

Now comes the real deal. How do we download the attachment? If you are thinking you can download the document using just the Download function and pass in the URL, it won’t work.

So what is the other way? One way can be using Power Automate to get the note content. But again we have the content of the file with us in the Canvas app. We can use the ThisItem.Document property to get the base64 content of the file. But how do we download the content as file.

I thought of writing a PCF control for that which I can use in my Canvas app which will create a downloadable link. But wait. Before you develop you, should try the wonderful PCF gallery. Trust me, there are some really cool stuffs in there and honestly I thought I will not find this. But I was surprised I found this – Canvas Apps downloader.

I went ahead and downloaded the solution and imported it my environment. Post that I did the below steps to use it in my canvas app.

Step 1 – Enable Power Apps Component framework for your environment.

Go to Power Platform Admin center and from Environment Settings -> Features enable the below option.

Step 2 – Enable Components for your Canvas App.

While this is enabled by default, just make sure you have it enabled for your app. In your App advanced settings, make sure you have the below setting enabled.

Step 3 – Add the PCF control inside Canvas app.

From your canvas app, select “Import Custom component

Select the Code tab and then your PCF control shall show up. Select your control that you want to import and then click on Import.

I followed all these steps and then I went and added the PCF control inside my Notes Gallery template.

It has four properties which are most important here.

The others are quite explanatory except for the download property. It’s a Boolean property. If you set this to true, the file will download immediately. I will come to that in a bit. Before that let’s fill out the other properties.

Below is the formula for filename.

Formula for File content property.

Another thing I do is OnVisible of the Notes Gallery screen, I set the below formula.

Now OnSelect of the download icon, I use the below formula.

And the final step is the download property of the PCF Control which I set to the below formula.

All set and done, below is the final stuff in action.

Hope this helped!

You might also like the below posts

Debajit Dutta
Business Solutions MVP


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading