cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helen_BB
Helper III
Helper III

Downloading a document in powerapps

Hello 🙂

 

in my powerapps i have a gallary with a sharepoint online document library - i have a download button with the following code:

 

onselect : Download(documenturl&"download.aspx")

 

this works perfectly well in chrome and downloads a copy for the user - however in Internet Explorer it does not download a copy instead it opens it from the server and then errors when the user tries to edit (as they dont have edit rights.) all i want it to do is download a copy.

 

Does anyone know why this is an issue and what i need to do to workaround this?

 

Thanks,

Helen.

 

11 REPLIES 11
v-monli-msft
Community Support
Community Support

Hi @Helen_BB,

 

To download file from SharePoint library in PowerApps, you could use the Link to item column directly. You do not need to add the 

"download.aspx" in the end of URL.

 

I just tested with below formula in IE:

Download(DataCardValue15.Text)

When selecting this button, the download pop-up shows and I can save the file correctly.

 

DataCardValue15 is the label control's name that holds the Link to item column inside the details form:

Untitled.png

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, thank you for your help.

Unfortunately this just opens up the file from the server rather than downloading the file. i only have the option to open and not to save as? (see attachment) 

 

when it is open its a read only file from the server. when errors when you try to edit 😞 

 

any ideas?

 

 

 

I found an alternate solution for this. I dont know if this has been explored or not. 

In my case, i found that the document file name with extenstion and Etag were the factors to consider.

I created a flow which gives the etag for the file which needs to be downloaded and we can just append the etag with the site url and use the Download function with the OnSelect of the button for download in powerapps like so : Download("https://<Your site URL>/_layouts/15/download.aspx?UniqueId="&etag);

Here "etag" is what you get from the flow as shown in the screenshots.

Before you write the Download function as mentioned above, you need to use a var like 'filepath' like so: 

Set(filePath,First(idattach_2.Attachments).Value&First(idattach_2.Attachments).Name) where idattach_2 is name of the attachment card. The 'Name' here would be '{FileNameWithExtension}' and 'Value' would be '{Path}' of the attachment card.

This 'filePath' will be the input parameter for the flow that returns the etag.

@anshulbatheja 

 

I used a flow (not the one you suggested) to get the ETag for the file I want users to download. Then I added it to the formula you suggested:

 

Download("[SITE URL]" & "/_layouts/15/download.aspx?UniqueId=" & "ETag")

 

This does nothing. Does it need to be the FILE URL instead of the SITE URL? What part of the URL needs to be replaced with the "/_layouts/15/download.aspx?UniqueId="? Please let me know.

Sorry for replying late, the URL needs to be the site url.

See if the popup to download file is blocked.

 

Function:

Download("https://<ur organization domain>.sharepoint.com/sites/<SITE Name>/_layouts/15/download.aspx?UniqueId..." & etag);

 

Example:

https://companyXYZ.sharepoint.com/sites/SITE XYZ/_layouts/15/download.aspx?UniqueId=D0BB0BFC-8117-4D7A-90AA-3EBE6D63A08D

DavidAR
Frequent Visitor

You can use this URL:

 

"http://<site URL>/_layouts/download.aspx?SourceUrl=/sites/sitename/library/folder/fileName.ext"

 

It's works with PowerApps.

Thank You @DavidAR for this , i just did it with Powerapps,and it work really fine.

Eligio
Regular Visitor

Thanks I solve the issue with this! 

Anonymous
Not applicable

@DavidAR i am trying to workout your solution for the download button but it says the document isn't found.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (19,905)