cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

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 Team
Community Support Team

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

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 Team
Community Support Team

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

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
Level: Powered On

Re: Patch and replace attachment in existing Sharepoint list item

I used:

 

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

and it worked great!!

PytByt
Level 8

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




Highlighted
amoncayo
Level: Powered On

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
Level 8

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?

amoncayo
Level: Powered On

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
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,316)