Hello everyone,
I have an App working with a SP list.
Users need to add or edit some attachments of an existing record.
Is there any way to accomplish this?
On previous threads I've read that Patch() doesn't work, and other methods work for a new record and not an existing one.
Any comments about this issue will be greatly appreciated.
Solved! Go to Solution.
Hi @efroseroc :
I strongly agree with @WarrenBelz .In theory, using editform control and submitform function is the only way to add attachments to existing records.
If you insist on using Patch function,you could consider take a try to only add the Attachments field within the Edit form. I have made a test on my side:
1\Add an edit form(Form3)
2\Add a button
OnSelect:
Patch( 'List A',/*'List A' is my data source*/ First('List A'),/*Modify the first record in the data source*/ {Title: "1"}, Form3.Updates )
On your side, you should type following formula:
Patch( 'YourSPList', 'Your specified record', { Column1:TextInput1.Text, Column2:TextInput2.Text, Column3:TextInput3.Text, ..., ColumnN:TextInputN.Text }, EditForm1.Updates )
Note: The Editform1 represents the Edit form control within your app, which only display the Attachments field.
I think these links will help you a lot:
https://powerusers.microsoft.com/t5/Building-Power-Apps/Saving-attachments-using-Patch/td-p/277984
Best Rergards,
Bof
Hi @efroseroc ,
The only way to add/delete and attachment and save it is with SubmitForm() - you cannot use Patch for this, however your question seems to suggest this is an issue?
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.
Hi @efroseroc :
I strongly agree with @WarrenBelz .In theory, using editform control and submitform function is the only way to add attachments to existing records.
If you insist on using Patch function,you could consider take a try to only add the Attachments field within the Edit form. I have made a test on my side:
1\Add an edit form(Form3)
2\Add a button
OnSelect:
Patch( 'List A',/*'List A' is my data source*/ First('List A'),/*Modify the first record in the data source*/ {Title: "1"}, Form3.Updates )
On your side, you should type following formula:
Patch( 'YourSPList', 'Your specified record', { Column1:TextInput1.Text, Column2:TextInput2.Text, Column3:TextInput3.Text, ..., ColumnN:TextInputN.Text }, EditForm1.Updates )
Note: The Editform1 represents the Edit form control within your app, which only display the Attachments field.
I think these links will help you a lot:
https://powerusers.microsoft.com/t5/Building-Power-Apps/Saving-attachments-using-Patch/td-p/277984
Best Rergards,
Bof
@v-bofeng-msft thank you for confirming my logic.
@efroseroc if you can confirm that you can do this - I was particularly interested in your statement
On previous threads I've read that Patch() doesn't work, and other methods work for a new record and not an existing one.
You can use SubmitForm() to save attachments on either new or existing records.
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.
I made a button with this code and it worked for saving the attachments and other changes in an existing record
Patch(
MySPList;
BrowseGallery1.Selected;
editForm.Updates
)
Thank you very much
Hi @WarrenBelz
The thing is that I was told that after editing an existing record other fields left untouched would disappear.
So I checked the code and they were using SubmitForm(), I investigated a little and found out that Patch() could be used for that kind of process.
So I used Patch() and for now the issue has not repeated, so I assumed that SubmitForm() was not just made for those purposes.
I see that I was mistaken, maybe the code was incorrect but I didn't make it and I can recall it.
Thank you for your feedback
Hi @efroseroc ,
You are not incorrect and have come across something I guess no one has tried. A Patch using FormName.Updates saves the attachment - I just tested it here as well. It does not however trigger the Form OnSuccess() Event.
@v-bofeng-msft - you might make a note of this.
SubmitForm() will also do the job - one small thing to remember is that all data cards on the form need an Update property, even if they are View mode.
User | Count |
---|---|
193 | |
127 | |
88 | |
48 | |
42 |
User | Count |
---|---|
279 | |
162 | |
136 | |
81 | |
78 |