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

How to use OnRemoveFile?

Hello,

 

To start off I am awful with collections so I would need guidance how to achieve this. I have an OnAddFile: 

Collect(colFiles,DataCardValue28_1.Attachments);
Collect(
colFinalData,
{
ID: ItemID.Text,
Name: Last(DataCardValue28_1.Attachments).Name,
DataStream: Image1.Image
}
)

 

Now I am trying to match what is inside colFinalData and using OnRemoveFile remove the attachment that was added by mistake, etc. How do you compare values between collections? 

10 REPLIES 10
PG_WorXz10
Community Champion
Community Champion

Hi @LukasSliuzas ,

 

May RemoveIf will work in your case. 

 

RemoveIf(colFinalData,ID=Value(ItemID.Text))

Or

RemoveIf(colFinalData,ID=ItemID.Text)

 

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.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

Hello,

 

None of these work because it just clears entire collection.

Hi @LukasSliuzas ,

 

the Removeif function will check ID=itemID.Text if only this condition satisfies it will remove. 

In your case on OnRemoveFile what is happening. 

 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

Hi @PG_WorXz10 

 

It still clears the entire collection and not that removed attachment

Hi @LukasSliuzas ,

 

This should not happen if IDs are unique. To get into more could you share a screen shot of the attachment controls and Remove item control. Also If possible could try adding some attachments and bind that collection in temporary gallery to check the IDs ? 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

LukasSliuzas
Helper II
Helper II

Here is the collection after adding the files

LukasSliuzas_0-1630398299226.png

 

Hi @LukasSliuzas ,

 

Here ID are same will you be able to use the IDD as it seems unique here ? 

Value(ItemID.Text) does this returns the ID or IDD value ?

 

RemoveIf(colFinalData,IDD=Value(ItemID.Text))

Or

RemoveIf(colFinalData,IDD=ItemID.Text)

 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

ItemID.Text returns as ID

Hi @LukasSliuzas 

 

Where are you triggering this OnRemove function ? Is it in the gallery or any other control ?

 

 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,293)