cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fsim
Helper II
Helper II

Adding a file by code to an attachments control

Hi everyone.

I have an approval app that allows user to add one or more files to a SP list. It works very well using a datacard and an attachments control.

I was ask to modify the app in order to start from another list, retreive the document on that other list and add it to the approval List via the app (and the attachments control).

So basically, what I want to do is to add a file to an attachments.

 

I'm able to launch my app from the second list. And I retreive the file (filename, full name and complete path) . I saved it in a collection. Now, how can I add it to the control ? With a Patch ? what's the default value then ?

Any help would be great ! Thank you

 

 

 

 

 

 

7 REPLIES 7
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @fsim ,

I think that is not possible yet, Now through Code.

See the below response - (Taken from one of the Post suggested by Microsoft Team members.)

See the limitation of attachment control:

Upload and delete functionality only work inside a form. Attachment control will look disabled when in Edit mode and not inside a form. Note that in order to save the file additions and deletions to the back end, the end user must save the form.

https://docs.microsoft.com/en-us/powerapps/controls/control-attachments

 

It seems that so far you cannot use Patch to upload the attachments to SharePoint. Please consider to add comments in below thread:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Save-attachments-to-SharePoint-list-item/idi-p/8...


Source - of Above mentioned Comment - https://powerusers.microsoft.com/t5/Building-Power-Apps/Patch-Attachments/td-p/98121


Thanks

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay

timl
Super User
Super User

Hi @fsim 

As you've probably figured out, file support in PowerApps is a bit limited.

To help develop some sort of workaround for you, are you looking to always add the files to a new record in your approval list (as opposed to appending files to an existing record in your approval list)?

@timl , yes it's not an append it's just adding one file  automatically (file that is retreived by a sharepoint collection at the start of the app)

 

@VijayTailor  Thank you for your answer. 

My attachment control is inside a form that said. Note that I wanted to patch the table behind the attachment control, not the Sharepoint list directly. In fact it's impossible that way, as the approval record don"t exist yet.

 

 

Hi @fsim ,

I don't think so this is also possible.
I agree with  @timl, as part of the attachment - some limitations here.

if you need a solution for the future regarding the same, please you can vote for the below Idea.
https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Allow-to-Patch-File-in-SharePoint-using-Absolut...
if you think that will useful for others also.
Thanks,

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay





@fsim - Would I be correct in thinking that so long as you can copy the contents of a SharePoint attachments field from one record in one list to a new record in another list, that would satisfy your requirement?

You wouldn't be too concerned if you don't use a collection? The reason I ask is because I believe this is possible, but not the exact way that you envisage. So I just want to clarify this before I describe this in more detail.

@timl 

absolutely ok with that !

thank you

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,993)