cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
elleeyl
Level: Powered On

Patch Attachment back to SharePoint List

Hi Community,

 

I am trying to patch an attachment back to SharePoint list. The attachment would be patched back together with other details as a new record.

 

I have read up similar threads on this topic on the forum. Based on them, I created Attachments is as a separate form (Form 3). The rest of the fields are Form2_1.

1.PNG

 

In the Submit button, I have tried the following 

 

Patch(Details, {'Header ID':HeaderID1, Title:DataCardValue37_1.Text,'Expense Amount':Value(DataCardValue44_1.Text),'Expense Date': DataCardValue45_1.SelectedDate});
Patch(Details,Defaults(Details), Form3.Updates);
UpdateContext({clearform:false});
UpdateContext({clearform:true});

 

and

 

Patch(Details, {'Header ID':HeaderID1, Title:DataCardValue37_1.Text,'Expense Amount':Value(DataCardValue44_1.Text),'Expense Date': DataCardValue45_1.SelectedDate});
Patch(Details,LookUp(Details,'Header ID'=HeaderID1), Form3.Updates);
UpdateContext({clearform:false});
UpdateContext({clearform:true});

 

However no attachments are patched back. There are also no error messages.

 

I also tried the below and it gives a message "Title: Field Required".

 

Patch(Details, {'Header ID':HeaderID1, Title:DataCardValue37_1.Text,'Expense Amount':Value(DataCardValue44_1.Text),'Expense Date': DataCardValue45_1.SelectedDate},Form3.Updates);

UpdateContext({clearform:false});
UpdateContext({clearform:true});

 

Please advise. Thanks.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Eelman
Level 8

Re: Patch Attachment back to SharePoint List

If you are happy using a Form and there's only one SP List to be updated then there's no need to use 2 Forms, one will do.

 

Add an EditForm to your app, select the SP List as your data source, Edit Fields and add in Attachments (if it's not shown), setout your form how you want it then you are done. To create a new item it's then just one line of code: 

SubmitForm(yourFormName)

 

Seems you are making this more complex than it needs to be or have I missed something?

View solution in original post

PowerAddict
Level 10

Re: Patch Attachment back to SharePoint List

There are situations in which SubmitForm doesn't work for Sharepoint. learnt it the hard way.

My suggestion is to use Form1.Updates within your Patch. For example:

Patch(datasource, Defaults(datasource), {Title: DataCardValue1.Text}, Form1.Updates)

Form1 is the only form in my example.

Let me know if it helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

View solution in original post

3 REPLIES 3
Eelman
Level 8

Re: Patch Attachment back to SharePoint List

If you are happy using a Form and there's only one SP List to be updated then there's no need to use 2 Forms, one will do.

 

Add an EditForm to your app, select the SP List as your data source, Edit Fields and add in Attachments (if it's not shown), setout your form how you want it then you are done. To create a new item it's then just one line of code: 

SubmitForm(yourFormName)

 

Seems you are making this more complex than it needs to be or have I missed something?

View solution in original post

PowerAddict
Level 10

Re: Patch Attachment back to SharePoint List

There are situations in which SubmitForm doesn't work for Sharepoint. learnt it the hard way.

My suggestion is to use Form1.Updates within your Patch. For example:

Patch(datasource, Defaults(datasource), {Title: DataCardValue1.Text}, Form1.Updates)

Form1 is the only form in my example.

Let me know if it helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

View solution in original post

elleeyl
Level: Powered On

Re: Patch Attachment back to SharePoint List

Thank you so much! That works 🙂

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,723)