cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
elleeyl 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
Eelman Resident Rockstar
Resident Rockstar

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

Super User
Super User

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 Resident Rockstar
Resident Rockstar

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

Super User
Super User

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 Helper III
Helper III

Re: Patch Attachment back to SharePoint List

Thank you so much! That works 🙂

Helpful resources

Announcements
secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,967)