Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

Remove item from collection if it matches in OnRemoveFile action



I got a collection of 4 collums that store list ID, Item ID, Name and DataStream. What I am trying to achieve is that I have an attachment control with function OnAddFile:

        Name: Last(DataCardValue127.Attachments).Name,
        DataStream: Image3.Image,
        IDD: CountRows(colFinalData)+1


Code above adds the attatchments to Sharepoint list without any issues but now the hard part (for me) is to remove the from collection if it was removed. Now I need to figure how to compare Collection Item name and the attachment control name 

Resolver II
Resolver II

I think we recently received possibility to add multiple attachments at once. I think your approach wont work when user add more than one attachment to form attachment card. 

in terms of removing items from collection there is some example:

my first collection,
ClearCollect(col1, {NAME: "Adam", ID: 1},{NAME: "Damian", ID: 2}, {NAME: "Piotr" , ID: 3})
my second collection,
ClearCollect(col2, {NAME: "Adam" , ID: 1},{NAME: "Tomasz", ID: 2}, {NAME: "Krzysztof" , ID: 3})

im removing from first collection items with NAME that exist in second collection

RemoveIf(col1, NAME in col2.NAME)

My solution to add multiple attachments work as I am pushing that collection into PowerAutomate flow. I just need a way to remove the item from collection on clicking X that WASN'T added to sharepoint yet

Resolver II
Resolver II

I don't understand why you are creating your file collection this way. Probably it has something with Power Automate and your feature.

my solution is:


Everytime i hit OnAddFile i clear and collect list of my datacrad attachments.
OnAddFile = ClearCollect(col1, DataCardValue13.Attachments)


On remove file i clear and collect second collection, this way i miss item i just deleted.

Then i remove from my first collection items that are not in my second collection.

OnRemoveFile = ClearCollect(col2, DataCardValue13.Attachments); RemoveIf(col1, !(Name in col2.Name))

I assume that first collection is one you are pushing to PowerAutomate.
Hope it will help you achive your goal, if yes thumb up please!

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

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

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (2,942)