web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Saving an attachment t...
Power Apps
Unanswered

Saving an attachment to a SharePoint library - from a customized list form

(0) ShareShare
ReportReport
Posted on by 312

I am working on a customized form for a SharePoint list. I need to save files that are uploaded to the attachments field to a SharePoint library. I have followed these instructions https://www.matthewdevaney.com/power-apps-easiest-way-to-upload-files-to-a-sharepoint-document-library/ and added a flow to my app, but when I add the suggested code (below) to the OnSelect property of my submit button, I am getting errors. (I swapped out "SubmitContract" with "SPIFlist," which is the name of my form. Screenshots of what I entered and the errors I am getting are below.)

 

The instructions worked perfectly (thank you @mdevaney!) so I suspect that the issue has to do with a) the fact that I am working from a list rather than grabbing the attachments field and deleting it - do I even need to include a submit button? (If it's relevant: in my current form, the submit button is in the Attachments data card, which is set to required) and b) that I'm very new to Power Apps 😉 

 

Any help in resolving my errors so my submit button triggers my flow would be very appreciated. I would also be open to doing things another way entirely if it makes more sense. Thanks in advance! 

 

UploadFileToDocumentLibrary.Run( { contentBytes: First(att_SubmitContract_AttachFile.Attachments).Value, name: First(att_SubmitContract_AttachFile.Attachments).Name } );

 

Screenshot 2023-01-10 at 9.28.10 AM.png

Screenshot 2023-01-10 at 9.28.48 AM.png

Categories:
I have the same question (0)
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Start by moving the button out of the Attachments data card.  Any kind of buttons that do something with your form need to be outside of the form.  

  • KBeale Profile Picture
    312 on at

    Thank you! But now I'm wondering if I need a submit button. If I have one, the user will have to click submit and and also save the form. Might there be a way to trigger the flow when the form is saved? 

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    You could try adding it to the OnSuccess property of the form.  This would only trigger it to run if the form was successfully submitted.

  • KBeale Profile Picture
    312 on at

    When I add the formula in the example I was following (below) I still get errors. Any suggestions for tweaks to make it work in a customized form for a list (v. a form where I added an upload action from a form and then deleted the form itself, as in the original example)? Thanks! 

     

    MyFlowName.Run( { contentBytes: First(att_MyFormName_AttachFile.Attachments).Value, name: First(att_MyFormName_AttachFile.Attachments).Name } );

  • MRoger Profile Picture
    20 on at

    The formula is missing something. It should be:

     

    UploadFileToDocumentLibrary.Run( { file: { contentBytes: First(att_SubmitContract_AttachFile.Attachments).Value, name: First(att_SubmitContract_AttachFile.Attachments).Name } } );

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard