cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lumberjacklurch Post Patron
Post Patron

Patch and replace attachment in existing Sharepoint list item

I feel like I keep hitting a brick wall with this...I am currently building a request app where a user can upload an attachment.  The request is returned to the user, they have an option to upload another file.  I only want one attachment per request.  How do I overwrite the inital attachment with a new attachment the user is providing?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support
Community Support

Re: Patch and replace attachment in existing Sharepoint list item

Hi @lumberjacklurch,

 

Could you please share a bit more about “replace the old attachment with the new one” that you mentioned?

Do you want to delete the old attachment from the SP list item, instead, add the new one?

I afraid that there is no way to achieve your needs in PowerApps currently.

 

As an alternative solution, you could consider take a try to only show  the newest attachment in your app, please take a try with the following workaround:

You can change the DetailForm’s Attachments’  DataCard.Deafult and EditForm’s Attachments’ DataCard.Default to Last(ThisItem.Attachments)

 

I test as this:

Attachments_DataCard2.Default: Last(ThisItem.Attachments)

Attachment_DataCard1.Default: Last(ThisItem.Attachments)

20190131patchreplaceattachment1.jpg

20190131patchreplaceattachment2.jpg

 

Result Test:

20190131replaceattachmenttest.gif

 

Hope this can be helpful.

Best Regards.

Yumia

 

View solution in original post

lumberjacklurch Post Patron
Post Patron

Re: Patch and replace attachment in existing Sharepoint list item

Yumia,

Thank you for the reply.  I did get it working...kind of.  What I was trying to do was replace the attachment via patch, and, you're right, it will not work that way.  So, I had to do it in a form.  Once I utilized the attachments control in a form, I upped the max allowed files from 1 to 2.  After populating the form with the selected item's data, the user can see (and then delete) the old file attachment and, at the same time, upload a new file attachment to replace it.  After that, I just used SubmitForm() to save the changes to the item.

View solution in original post

7 REPLIES 7
Community Support
Community Support

Re: Patch and replace attachment in existing Sharepoint list item

Hi @lumberjacklurch,

 

Could you please share a bit more about “replace the old attachment with the new one” that you mentioned?

Do you want to delete the old attachment from the SP list item, instead, add the new one?

I afraid that there is no way to achieve your needs in PowerApps currently.

 

As an alternative solution, you could consider take a try to only show  the newest attachment in your app, please take a try with the following workaround:

You can change the DetailForm’s Attachments’  DataCard.Deafult and EditForm’s Attachments’ DataCard.Default to Last(ThisItem.Attachments)

 

I test as this:

Attachments_DataCard2.Default: Last(ThisItem.Attachments)

Attachment_DataCard1.Default: Last(ThisItem.Attachments)

20190131patchreplaceattachment1.jpg

20190131patchreplaceattachment2.jpg

 

Result Test:

20190131replaceattachmenttest.gif

 

Hope this can be helpful.

Best Regards.

Yumia

 

View solution in original post

lumberjacklurch Post Patron
Post Patron

Re: Patch and replace attachment in existing Sharepoint list item

Yumia,

Thank you for the reply.  I did get it working...kind of.  What I was trying to do was replace the attachment via patch, and, you're right, it will not work that way.  So, I had to do it in a form.  Once I utilized the attachments control in a form, I upped the max allowed files from 1 to 2.  After populating the form with the selected item's data, the user can see (and then delete) the old file attachment and, at the same time, upload a new file attachment to replace it.  After that, I just used SubmitForm() to save the changes to the item.

View solution in original post

amoncayo
Frequent Visitor

Re: Patch and replace attachment in existing Sharepoint list item

I used:

 

Patch(source, Default(Source), {Record}, FormName.Updates) 

and it worked great!!

PytByt Post Prodigy
Post Prodigy

Re: Patch and replace attachment in existing Sharepoint list item


@amoncayo wrote:

I used:

 

Patch(source, Default(Source), {Record}, FormName.Updates) 

and it worked great!!


Hi @amoncayo  and @v-yuxima-msft 

I also need to add new attachment to the same record in the same SP List. 

I use submitform and it keeping creating new record in the same SP List. What i need is the new attachment is adding to the same record, so i can have many attachment in the same record field in my SP List items.

 

is it possible?

 

thanks,

pytbyt




amoncayo
Frequent Visitor

Re: Patch and replace attachment in existing Sharepoint list item

I know there is a 10mb max for attachments, you may have to use Collect and create a gallery. 

PytByt Post Prodigy
Post Prodigy

Re: Patch and replace attachment in existing Sharepoint list item


@amoncayo wrote:

I know there is a 10mb max for attachments, you may have to use Collect and create a gallery. 


@amoncayo 

i thought that the size can we customize? no?

Highlighted
amoncayo
Frequent Visitor

Re: Patch and replace attachment in existing Sharepoint list item

A control that allows users to download files to their device, as well as upload and delete files from a SharePoint list or a Common Data Service entity.

Limitations

The attachment control has these limitations:

  1. Attachments are supported with SharePoint lists and Common Data Service entities.

  2. Upload and delete functionality work only inside a form. The Attachment control appears disabled when in Edit mode and not inside a form. To save file additions and deletions, the app user must save the form. Because of this limitation, the Attachment control isn't available from the Insert tab but appears in the form when the Attachment form field is enabled in a SharePoint or Common Data Service form.

  3. You can upload files only if they're 10 MB or smaller.

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

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!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

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