Skip to main content

Notifications

Community site session details

Community site session details

Session Id : nURDh2ybYC0LCs7hEjVLEm
Power Apps - Building Power Apps
Answered

Patch Attachments to Sharepoint List

Like (0) ShareShare
ReportReport
Posted on 9 May 2022 14:26:05 by

Hi Experts,

 

I'm trying to add attachments from a peninput and also an attachment control into a sharepoint list, i'm trying to avoid having to use power automate as i'd rather everything was in powerapps for ease. Everything with my code is working perfectly apart from getting the attachments into the sharepoint list along with the rest of the data being captured and sent to the list. I've seen that when using patch, you can use a Lookup to get the attachments in but i've no idea where to put it, have you any ideas please? 

 

ClearCollect(
colImages,
AddColumns(
RenameColumns(
AttachmentControl.Attachments,
"Value",
"ContentBytes"
),
"@odata.type",
""
),
{
Name: "Signature.jpg",
ContentBytes: Signature.Image
}
);

Office365Outlook.SendEmailV2("installation@MYDOMAINNAME.com" , 'Result Job Number'.Text , "Hi,<br><br>

Please see completed survey form below and attached drawings<br><br>

<a href=https://MYDOMAINNAME.sharepoint.com/sites/PowerApps/Lists/DoorSurvey/AllItems.aspx>Click Here to View the Full SharePoint List</a><br><br>

<b>Survey Complete?: </b>"&ValueSurveyStatus&"<br>
<b>Customer: </b>"&Customer.Text&"<br>
<b>Address: </b>"&Address.Text&"<br>
<b>Job Number: </b>"&'Job Number'&"<br>
<b>Surveyor: </b>"&Surveyor.Text&"<br>
<b>Date: </b>"&Date.SelectedDate&"<br><br>

<b>Door Ref: </b>"&'Door Ref'&"<br>

<b>Existing Door to Remove: </b>"&ValueExistingDoorToRemove&"<br>
<b>Existing Access Control, Alarm etc: </b>"&ValueExistingAccessControl&"<br>
<b>S/O Substrate: </b>"&'S/O Substrate'&"<br>
<b>Cavity Closer Plates Required: </b>"&ValueCavityCloser&"<br>
<b>Recommended Steel Trim: </b>"&ValueSteelTrim&"<br>
<b>Ancillary Items: </b>"&Ancillary&"<br>
<b>Door Location on Site: </b>"&'Door Location'&"<br>
<b>Clear Access Route: </b>"&ValueClearAccess&"<br>
<b>Team Size: </b>"&'Team Size'&"<br>
<b>Additional Site Equipment: </b>"&'Additional Site Equipment'&"<br>
<b>Onsite Parking: </b>"&ValueOnsiteParking&"<br><br>

<b>Notes: </b>"&Notes&"<br><br>

Regards<br><br>

IT Department<br></br>",
{Attachments: colImages}
);
Reset(AttachmentControl);
Reset(Signature)
;
Patch(DoorSurvey, Defaults(DoorSurvey),
{
SurveyStatus: ValueSurveyStatus.Text,
Title: ValueDateTimeNow.Text,
Customer: Customer.Text,
'Site Address': Address.Text,
'Job Number': 'Job Number'.Text,
Surveyor: Surveyor.Text,
Date: Date.SelectedDate,
'Door Ref': 'Door Ref'.Text,
'Existing Door to Remove': ValueExistingDoorToRemove.Text,
'Existing Access Control, Alarm etc': ValueExistingAccessControl.Text,
'S/O Substrate': 'S/O Substrate'.Text,
'Cavity Closer Plates Required': ValueCavityCloser.Text,
'Recommended Steel Trim': ValueSteelTrim.Text,
'Ancillary Items': Ancillary.Text,
'Door Location on Site': 'Door Location'.Text,
'Clear Access Route': ValueClearAccess.Text,
'Team Size': 'Team Size'.Text,
'Additional Site Equipment': 'Additional Site Equipment'.Text,
'Onsite Parking': ValueOnsiteParking.Text,
Notes: Notes.Text
});
Navigate(Success,Cover)

  • Suggested answer
    TimMiles Profile Picture
    6 on 11 Mar 2025 at 12:52:58
    Patch Attachments to Sharepoint List
    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);
  • Verified answer
    v-bofeng-msft Profile Picture
    on 12 May 2022 at 05:22:29
    Re: Patch Attachments to Sharepoint List

    Hi @Dave-ITMan ,

     

    If you want to patch/Update the the attachments file to your SP list individually using Patch/Update function, I afraid that there is no way to achieve your needs in PowerApps currently.

    As an alternative solution, you need to consider your Edit form data as a Whole, and type it within your Patch/Update formula. I have made a test on my side, please take a try with the following workaround:

    1\Create an edit form(Form1) and set it's data source

    vbofengmsft_0-1652332907905.png

     

    2\edit fileds(Leave only the attachments field)

    vbofengmsft_1-1652332907917.png

     

    3\Modify the update if formula:

     

    UpdateIf(Table1,true,Form1.Updates)

     

     

    The Result:

    vbofengmsft_2-1652332907918.png

     

    I think this link will help you a lot:
    Saving attachments using Patch 

    Best Regards,

    Bof

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,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started