cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HansHeintz
Level 8

if gallery items is collection then gallery.selected understood by editform but not by remove

If a gallery shows a collection from a datasource (clearcollect etc) and I open an editform with item set to gallery.selected all goed well. But if I do remove(datasource,gallery.selected) it is erroneous.

Why is this?

How can I adress this record from remove without doing a locate or filter? Is there some system inherent record identifier?

1 ACCEPTED SOLUTION

Accepted Solutions
HansHeintz
Level 8

Re: if gallery items is collection then gallery.selected understood by editform but not by remove

I found a solution that for me is somewhat more satisfying . 

First I created a guid field for my table and do a lookup on that value but then when I looked at the collection in the "weergeven - verzamelingen" (translate: show collections?, why o why do i have to work in a dutch interface it, makes all support and searching for support so much more difficult, is there one develloper in the world who cannot read english?) and guess what:

there *is* already a system inherent guid field in a powerapps entity (in my case it is called cra27_diereventid) and I can use that.

View solution in original post

5 REPLIES 5
Super User
Super User

Re: if gallery items is collection then gallery.selected understood by editform but not by remove

You are removing it from a collection so you need to use a remove that matches the collection data for that row or a removeIf that will find the row you want.  In your case if the collection has a unique ID you could reference that in a removeif.

 

When I create a collection I generally just tke the collection part of the ClearCollect and then place Remove at the start.  This then matches the line you wat to remove but if there are multiple lines the same they will all be removed.

 

EG: ClearCollect(varcoll1,Datasource,{-----:-------}) to Remove(varcoll1,{-------:-----})

Community Support Team
Community Support Team

Re: if gallery items is collection then gallery.selected understood by editform but not by remove

Hi @HansHeintz 

 

Could you please try formula expression as this ?

Remove(CollecitonName,LookUp(CollectionName,ColumnName=Gallery1.Selected.ColumnName))

 

I test on my side as next:

Button_Collection.OnSelect=ClearCollect( Customers, Table( { Name: "Fred Garcia", Company: "Northwind Traders" }, { Name: "Cole Miller", Company: "Contoso" }, { Name: "Glenda Johnson", Company: "Contoso" }, { Name: "Mike Collins", Company: "Adventure Works" }, { Name: "Colleen Jones", Company: "Adventure Works" } ) )

 

Gallery1.Items=Customers

 

Button_Remove.OnSelect=Remove(Customers,LookUp(Customers,Company=Gallery1.Selected.Company))

 

RemoveRecordFromCollection.gif

 

Hope this could be helpful.

 

Best Regards.

Yumia

 

Super User
Super User

Re: if gallery items is collection then gallery.selected understood by editform but not by remove


Could you please try formula expression as this ?

Remove(CollecitonName,LookUp(CollectionName,ColumnName=Gallery1.Selected.ColumnName))

 


You could aslo use 

Remove(CollecitonName,LookUp(CollectionName,ColumnName=ThisItem.(name of column)))

 

But beware unless the result is unique it will remove every row in the collection that matches

HansHeintz
Level 8

Re: if gallery items is collection then gallery.selected understood by editform but not by remove

I found a solution that for me is somewhat more satisfying . 

First I created a guid field for my table and do a lookup on that value but then when I looked at the collection in the "weergeven - verzamelingen" (translate: show collections?, why o why do i have to work in a dutch interface it, makes all support and searching for support so much more difficult, is there one develloper in the world who cannot read english?) and guess what:

there *is* already a system inherent guid field in a powerapps entity (in my case it is called cra27_diereventid) and I can use that.

View solution in original post

HansHeintz
Level 8

Re: if gallery items is collection then gallery.selected understood by editform but not by remove

The inherent id field is not as readily available as other fields (it is also not suggested while typing) but it works like this:

In the onvisible of the form

UpdateContext({CurrentRecord:LookUp(DierEvent;cra27_diereventid=GalleryDierEvent.Selected.cra27_diereventid)})

In the item property of the editform

CurrentRecord

As the delete action

Remove(DierEvent;CurrentRecord) 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (6,127)