cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Issue with deleting items in gallery

Hi, I'm having an issue with a delete icon in each Gallery item. The code is as below, and for some reason if I don't have the SaveData() code it won't delete the item (sometimes it'll only successfully delete the top item). But if I only have the remove() function it'll delete as it should. I've also tried to call a Timer outside the Gallery to use the SaveData() function but if that code's in there it'll give me the same result as if I had the SaveData() back in. But I know the SaveData() works, because if you deleted the item, the "Back" and "Proceed" buttons have the SaveData() functions in them and if you deleted and hit one of those buttons it would work. I'm wanting the SaveData() in the delete icon, as the photos are saved until they're dealt with or deleted. (also attached is an image of what the Gallery looks like)
Many thanks!


Delete Icon Code:

If(
    ThisItem.IsSelected,
    Remove(
        PhotoCollection,
        ThisItem
    );
    SaveData(
        PhotoCollection,
        "tempCameraStorage"
    )
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @Hench ,

 

I can't get your point. What do you want to achieve?

The formula you post doesn't make any sense, 'ThisItem.IsSelected' always returns true when the delete icon is selected, so only remove function can be triggered.

 

In addition, there is also a potential mistake. Since you are trying to remove items from collection,  the entire record must match. Reference from Remove function . However, What 'ThisItem' returns doesn't match the entire record, which also contains some control information within the gallery.

The workaround is to use LookUp function to retrieve the entire record from collection through Unique identifier field.

Remove(PhotoCollection, LookUp(PhotoCollection, GUIDField=ThisItem.GUIDField))

 

Sik

 

View solution in original post

1 REPLY 1
Community Support
Community Support

Hi @Hench ,

 

I can't get your point. What do you want to achieve?

The formula you post doesn't make any sense, 'ThisItem.IsSelected' always returns true when the delete icon is selected, so only remove function can be triggered.

 

In addition, there is also a potential mistake. Since you are trying to remove items from collection,  the entire record must match. Reference from Remove function . However, What 'ThisItem' returns doesn't match the entire record, which also contains some control information within the gallery.

The workaround is to use LookUp function to retrieve the entire record from collection through Unique identifier field.

Remove(PhotoCollection, LookUp(PhotoCollection, GUIDField=ThisItem.GUIDField))

 

Sik

 

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (101,270)