cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Remove an item from a collection that is populated with an attachment control

I have a collection that is completed when you add an attachment to an attachment control in the case of adding a file. I put the following formula

Collect(
Excels,
{
First Name: Last(attExcel.Attachments) .Name,
DataStream: Last(attExcel.Attachments) .Value
}
)

 

Now, in case the attachment in the control is deleted, I also want to remove it from the collection

Do you have any idea how to achieve this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @King ,

You just need to ClearCollect the remaining attachments

ClearCollect(
Excels,
   {
      First Name: attExcel.Attachments.Name,
      DataStream: attExcel.Attachments.Value
   }
)

I do this on every attach and delete - simply creates a new collection with the current attachments.

If you don't need to rename the fields 

ClearCollect(
   Excels,
   attExcel.Attachments
)

This will have two fields - Name and Value. The Value will show as an image in an image control if required.

 

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.

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

Hi King,

Just collect again on the OnRemoveFile property of the attachment control.

 

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.

Highlighted
Helper V
Helper V

nevermind he's got ya

Highlighted

Hi @WarrenBelzthanks for answering

 

I did what he told me and what he does is create a new blank record in the collection without deleting the previous one.

Highlighted

Hi @King ,

You just need to ClearCollect the remaining attachments

ClearCollect(
Excels,
   {
      First Name: attExcel.Attachments.Name,
      DataStream: attExcel.Attachments.Value
   }
)

I do this on every attach and delete - simply creates a new collection with the current attachments.

If you don't need to rename the fields 

ClearCollect(
   Excels,
   attExcel.Attachments
)

This will have two fields - Name and Value. The Value will show as an image in an image control if required.

 

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.

View solution in original post

Highlighted

Hi @WarrenBelz 

Thank you  for your help, what helped me in my case was the second formula indicated by you.

 

ClearCollect (
Excels,
attExcel.Attachments
)

which forced me to rename my collection columns called

FirstName and DataStream to
Name and value

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,914)