cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Method to Remove items from local Collection

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!!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Advocate III
Advocate III

Re: Method to Remove items from local Collection

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,

View solution in original post

Advocate III
Advocate III

Re: Method to Remove items from local Collection

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,

 

View solution in original post

13 REPLIES 13
Highlighted
Advocate III
Advocate III

Re: Method to Remove items from local Collection

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,

Highlighted
Anonymous
Not applicable

Re: Method to Remove items from local Collection

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

 

 

Highlighted
Advocate III
Advocate III

Re: Method to Remove items from local Collection

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,

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Method to Remove items from local Collection

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

Highlighted
Advocate III
Advocate III

Re: Method to Remove items from local Collection

Try to replace "," with ";"

 

Regards,

Highlighted
Anonymous
Not applicable

Re: Method to Remove items from local Collection

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

  •    Expected 'CurlyClose'; Found 'Semicolon'
  •    Invalid number of parameters
Highlighted
Anonymous
Not applicable

Re: Method to Remove items from local Collection

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.

Advocate III
Advocate III

Re: Method to Remove items from local Collection

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,

 

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Method to Remove items from local Collection

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?

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,450)