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

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.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,677)