web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Method to Remove items...
Power Apps
Answered

Method to Remove items from local Collection

(0) ShareShare
ReportReport
Posted on by

I have an app that will collect information in a local Collection. Once the user approves the data within the Collection, the entire Collection is then Patched to the Common Data Service.

 

I am struggling getting the Remove() function to work with a local Collection. It has always worked properly whenever used with a connected data source (such as Microsoft CDS), but I cannot get it to remove a single row from a local colllection.

 

PA2.PNG

 

I have also tried placing the Delete Icon inside a DataCard element of the EditForm (and used ThisItem instead of Gallery.Selected), but it did not work either.

 

What's the best way to Remove from a local Collection?

 

Thank you!!

Categories:
I have the same question (0)
  • Brank Profile Picture
    149 on at

    What kind of information do you have in your gallery? I try to reproduce your problem but in my case it is working. This is what I did.

     

    On property "OnVisible" of the screen: Collect(test;[1;2;3;4;5])

    On Gallery "Items" property: test

    On "OnClick" property of a button: Remove(test;{Value: Gallery1.Selected.Value})

     

    If you select and then press the button that row is deleted. It is true that if you just put in the second parameter of Remove: "Gallery1.Selected" this wont work, it seems you have to put the register with "{ }" and giving an id value.

     

    Regards,

  • Community Power Platform Member Profile Picture
    on at

    It is just a Text Gallery with a few fields.

    pa.PNG

     

     

    I cannot get the {Value: Gallery1.Selected.Value} to work either. The system says .Value is an Invalid Name.

     

    Capture.PNG

     

     

  • Verified answer
    Brank Profile Picture
    149 on at

    It is clear "value" wont work for you beacuse it works only in my example. 

     

    In this case you can do it in two ways:

     

    - If "Cultivar" wont repeat in your gallery you can use it in the remove method for identify which register you want to delete. Something like this Remove(PP;{Cultivar: Gallery1.Selected.Cultivar})

     

    - If "Cultivar" can repeat in different registers you should use all fields in the gallery item for identify the register you want to delete, something like this: Remove(PP;{Cultivar: Gallery1.Selected.Culvitar; Bench: Gallery1.Selected.Bench; Severity: Gallery1.Selected.Severity....etc etc etc}

     

    Regards,

  • Community Power Platform Member Profile Picture
    on at

    Thank you!

     

    I see how it should be excecuted, but for some reason, it still does not remove the item from the Collection or Gallery.

     

    Capture.PNG

  • Brank Profile Picture
    149 on at

    Try to replace "," with ";"

     

    Regards,

  • Community Power Platform Member Profile Picture
    on at

    I get Errors when I try semicolons, like your example.

    •    Expected 'CurlyClose'; Found 'Semicolon'
    •    Invalid number of parameters
  • Community Power Platform Member Profile Picture
    on at

    Thank you, Brank!!

     

    The issue was not specifing more specifically which item to Remove.

     

    The final code needed to include all columns in order to specify the exact record to remove from the collection. 

     

     

     

     

    The documentation should be updated to reflect this issue with local collections.

  • Verified answer
    Brank Profile Picture
    149 on at

    I am glad that it works good for you now, but anyway I would use an "id" column that is hided by the use so it would be easier to erase the record using the LookUp function, with something like this:

     

    Remove(PP,LookUp(PP, ID = Gallery1.Selected.ID))

    In this case you wont have to put all columns for erase one record. Also you are sure which record you are erasing because id cannot be repeated.

     

    I am agree with you that the documentation should be updated because you work with "," and every app I made have to be with ";", this is maybe because I am working with the web developing tools and you are using the Windows Studio..

     

    Who knows?

     

    Regards,

     

  • Community Power Platform Member Profile Picture
    on at

    Is it possible to reference system-generated fiels like RecordID, or would I need to add a new field that is controlled within the app?

  • Brank Profile Picture
    149 on at

    What you are talking about seems to be using CDS (Common Data Service). If you are using a CDS as Data Source of course you can use the system-generated columns such as RecordID. This is just if you are using CDS, in the case of local collections you should made yourself a RecordID column because collections don't generate this automatically this data. For example if you create a collection just like this:

     

    Collect(PP;[1;2;3;4;5]) you can see that it will create a table called PP and it will only have 1 column called "Value", this is because "Value" is the default name of the column if we don't define it explicitly.

     

    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard