cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
efroseroc
Helper II
Helper II

Adding attachments to an existing record

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

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
)

20.gif

 

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/Need-to-add-Attachment-to-a-PATCH-to-a-Share...

https://powerusers.microsoft.com/t5/Building-Power-Apps/Saving-attachments-using-Patch/td-p/277984

Best Rergards,

Bof

View solution in original post

6 REPLIES 6
WarrenBelz
Super User III
Super User III

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.

v-bofeng-msft
Community Support
Community Support

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
)

20.gif

 

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/Need-to-add-Attachment-to-a-PATCH-to-a-Share...

https://powerusers.microsoft.com/t5/Building-Power-Apps/Saving-attachments-using-Patch/td-p/277984

Best Rergards,

Bof

View solution in original post

@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.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (48,968)