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 / Patching Attachments t...
Power Apps
Suggested Answer

Patching Attachments to a SharePoint List - Not Edit Form

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    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

     

     

  • golfnutt82 Profile Picture
    1,360 on at

    Thanks Warren,

  • golfnutt82 Profile Picture
    1,360 on at

    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?

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    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 at

    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!

  • Suggested answer
    TimMiles Profile Picture
    6 on at
    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);
  • TimMiles Profile Picture
    6 on at
    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
                            }
                            ))
    )
  • NathanFra Profile Picture
    183 on at
    @TimMiles, how did you get this working? I'm trying to do something similar but receive a generic Patch 'error'
    ForAll(
                colAdditionalMedications,
                Patch(
                    'Chain Of Custody Medication',
                    Defaults('Chain Of Custody Medication'),
                    {
                        ParentID: varChainOfCustodyMasterRecord.ID,
                        Title: MedicationName,
                        Strength: Strength,
                        LotNumber: LotNum,
                        ExpirationDate:ExpDate,
                        Quantity: Quantity,
                        MedType: MedType,
                        Attachments:
                        Table(ForAll(Gallery2.AllItems,
                        {
                        DisplayName:ID & "Photo.png",
                        AbsoluteUri:Blank(),
                        Id:ID,
                        Value:Value
                        }
                        )
                        )
                    }
                )
            )


     
     
     

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard