cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
King
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

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

TheRobRush
Helper V
Helper V

nevermind he's got ya

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.

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

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
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (58,474)