cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

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
Highlighted
Super User II
Super User II

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

Highlighted

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
Highlighted
Super User II
Super User II

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

Highlighted

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

Highlighted

Thank you so much! That works 🙂

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (12,650)