Skip to main content

Notifications

Community site session details

Community site session details

Session Id : PV2xf/GbelsiBVJeRIjCgc
Power Apps - Building Power Apps
Suggested answer

Patching Attachments to a SharePoint List - Not Edit Form

Like (0) ShareShare
ReportReport
Posted on 16 Feb 2023 14:50:26 by 1,360

Hello,


I am trying to update my patch function that will allow me to upload an attached file.
I have two forms and each one is different because I was not the original developer.
The first form uses containers and the second form uses datacards.

golfnutt82_1-1676558620880.png

I have tried to update the below code that will allow me to upload any attachments when the patch function is initiated but the patch complains.

 

golfnutt82_0-1676558328017.png

Saw a lot of things online but they all seem to reference an edit form.

 

Categories:
  • TimMiles Profile Picture
    6 on 11 Mar 2025 at 14:54:53
    Patching Attachments to a SharePoint List - Not Edit Form
    Extending on my first post. You can add multiple attachments using the below code. I had to funnel my attachments through a gallery as the datatype for the Value column in the attachment table is particular to certain types like images, blob
     
    Patch(AisleAuditTransactions,Defaults(AisleAuditTransactions),
            {
               Title:"SlotQuality Issue",
               Attachments:Table(ForAll(Gallery2.AllItems,
                            {
                            DisplayName: TextCanvas4.Text & "SlotQualityIssueimage.jpg",
                            AbsoluteUri: Blank(),
                            Id: TextCanvas4.Text,
                            Value: Image3.Image
                            }
                            ))
    )
  • Suggested answer
    TimMiles Profile Picture
    6 on 11 Mar 2025 at 12:41:12
    Patching Attachments to a SharePoint List - Not Edit Form
    I was able to patch directly to a sharepoint list attachment field using the following. Note the first part captures a screenshot using the PDF control and stores it in appres://blobmanager. Then using the table format below in patch, it patches it to the sharepoint list. I havent tried multiple items yet, or how to patch into an attachment field that already has attachments. But this does work
     
    //Capture screenshot
    Set(VarEmployeeSignedDocument, PDF(Testing));
     
    //Patch screenshot to attachments field
    Patch(AisleAuditTransactions,Defaults(AisleAuditTransactions),
            {
               Title:" Test",
               Attachments:Table(
                            {
                                DisplayName: "TestAttachScreenshot.pdf" ,
                                AbsoluteUri: Blank() ,
                                Id: VarEmployeeSignedDocument,
                                Value: VarEmployeeSignedDocument
                            })
            });
     
    Notify("Success", NotificationType.Success,1500);
  • golfnutt82 Profile Picture
    1,360 on 18 Feb 2023 at 12:40:13
    Re: Patching Attachments to a SharePoint List - Not Edit Form

    Hi Warren,
    Yes, good point about the submitting the form and creating a separate new record from the patch. I agree that maybe submitting the form thus adding the attachment(s) to the record and then run the patch using "OnSuccess" property and leveraging the ID from LastSubmit may work. Definately will look at this Monday.
    Thanks for your insight!

  • WarrenBelz Profile Picture
    146,660 Most Valuable Professional on 17 Feb 2023 at 22:00:22
    Re: Patching Attachments to a SharePoint List - Not Edit Form

    Hi @golfnutt82 ,

    I must admit that is a new one on me (though I have never tried it) - you may have to add another field to the form (you can hide it). .Updates should work on new and Edit, however beware on New it will create a new record separate from the Patch. To be honest the best way would be to submit the Form with the Attachments then run your Patch OnSuccess using the ID from LastSubmit.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • golfnutt82 Profile Picture
    1,360 on 17 Feb 2023 at 16:24:28
    Re: Patching Attachments to a SharePoint List - Not Edit Form

    Hi Warren,

    I was able to add a form.

    golfnutt82_0-1676652768536.png

    Here are the datacard details.

    golfnutt82_1-1676652825928.png

    When I attempt to update the patch using Attachments_Form1.Updates the patch function complains because it only finds Attachments:

    golfnutt82_2-1676653180239.png

     


    So, is Patch(FormName.Updates) for a New or Edit form or both?
    Would I be able to use this within my current patch?

  • golfnutt82 Profile Picture
    1,360 on 17 Feb 2023 at 15:05:33
    Re: Patching Attachments to a SharePoint List - Not Edit Form

    Thanks Warren,

  • WarrenBelz Profile Picture
    146,660 Most Valuable Professional on 16 Feb 2023 at 21:23:48
    Re: Patching Attachments to a SharePoint List - Not Edit Form

    Hi @golfnutt82 ,

    The only way you can upload attachements directly from Power Apps is with an Attachment control in a Form, either by using SubmitForm() or Patch(FormName.Updates). It is possible using Power Automate to export the content (involves a hidden Image control and using JSON to get Base64 from that) and then using Add Attachment  but this would also be one at a time as they are attached.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started