cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
panterra
Level: Powered On

Remove() and RemoveIf() functions not working on iPhone

Hi folks,

 

Here is the scenario:

  • When an item is selected in a gallery, I am adding it to a collection (collIPPOfflineCache) so that it may be recalled in a later screen.
    • The items in the gallery are sourced from a SQL table
    • The main reason I am sending the selected items to a collection is so that they can be recalled at a later time, while the user is Offline
  • Before adding an item to the collection, I make an attempt to remove it.
    • This way, I won't end up with duplicate records in my collection if the user selects the same item multiple times
  • This pattern works fine on the Windows client.  However, it fails to work on the iPhone.

On the iPhone, each of the attempts below will remove all items from the collection instead of the item isolated in the function.  All code in this example is running from the Gallery's OnSelect event.

 

  • //Removes All Items from the Collection - on the iPhone 2.0.707 Build
    Remove(collIPPOfflineCache, LookUp(collIPPOfflineCache, IPP_Id=gallSearchResultsOnline.Selected.Id ));

    //Removes All Items from the Collection - on the iPhone 2.0.707 Build
    RemoveIf(collIPPOfflineCache, IPP_Id=gallSearchResultsOnline.Selected.Id);

    //Removes All items from the Collection - on the iPhone 2.0.707 Build
    Remove(collIPPOfflineCache, Filter(collIPPOfflineCache, IPP_Id=gallSearchResultsOnline.Selected.Id));

 

Has anyone else had any luck in removing a specific item from a local PowerApps collection?

1 ACCEPTED SOLUTION

Accepted Solutions
panterra
Level: Powered On

Re: Remove() and RemoveIf() functions not working on iPhone build 7.0.707

I've implemented a work around that seems to get by. 

  • Your comment about where I was declaring / creating the collection lead me to declare the collection in the Main screen's OnStart Event
  • I've used a method of copying the main collection into a temporary one - without including the item that was selected in the Gallery's OnSelect event

Delcaring a Collection in the Main screen's OnStart Event

I'm assuming that in PowerApps code execution cycle, the first time that the collection is referenced is where it's declared.  I chose to declare an instance of the collection in the Main screen of the App's OnStart event.  This will make for some cleanup code later.

 

Removing an Item from a PowerApps Collection 

The script below runs in the Gallery's OnSelect event.

 

//Copy the collection over to a temporary collection - exclude the item that has been selected. 

ClearCollect(tempcollIPPOfflineCache,Filter(collIPPOfflineCache, IPP_Id<>gallSearchResultsOnline.Selected.Id));
ClearCollect(tempcollIPPDetails,Filter(collIPPDetails, IPP_Id<>gallSearchResultsOnline.Selected.Id) );

 

//Complete the action by copying the temporary collection back to the source collection

ClearCollect(collIPPOfflineCache, tempcollIPPOfflineCache);
ClearCollect(collIPPDetails, tempcollIPPDetails);

 

 

5 REPLIES 5
Community Support Team
Community Support Team

Re: Remove() and RemoveIf() functions not working on iPhone build 7.0.707

Hi @panterra,

 

Could you please share more details about the following part:

"

Before adding an item to the collection, I make an attempt to remove it.

  • This way, I won't end up with duplicate records in my collection if the user selects the same item multiple times

"

Any function here you used to prevent duplicate record?

How the collection is created, is the formula for the collection creation also with the Onselect property of the Gallery control?

 

Further, PowerApps Mobile current version is 2.0.712, take a try to update and see if that would make the formula work.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
panterra
Level: Powered On

Re: Remove() and RemoveIf() functions not working on iPhone build 7.0.707

@v-micsh-msft - thank you for responding!

 

Here are my answers to your questions:

  1. Any of the above functions I listed are having the same effect.  All of the items are actually being removed from the collection.  It should only be removing the single item(s) that I specify.
  2. Yes - The collection is being created in script in the Gallery's OnSelect event.
  3. I have tried the new version of the mobile app on my iPhone (2.0.714) and see the same problem.

Let me know if you have any other questions. 

 

Sean

 

 

panterra
Level: Powered On

Re: Remove() and RemoveIf() functions not working on iPhone build 7.0.707

I've implemented a work around that seems to get by. 

  • Your comment about where I was declaring / creating the collection lead me to declare the collection in the Main screen's OnStart Event
  • I've used a method of copying the main collection into a temporary one - without including the item that was selected in the Gallery's OnSelect event

Delcaring a Collection in the Main screen's OnStart Event

I'm assuming that in PowerApps code execution cycle, the first time that the collection is referenced is where it's declared.  I chose to declare an instance of the collection in the Main screen of the App's OnStart event.  This will make for some cleanup code later.

 

Removing an Item from a PowerApps Collection 

The script below runs in the Gallery's OnSelect event.

 

//Copy the collection over to a temporary collection - exclude the item that has been selected. 

ClearCollect(tempcollIPPOfflineCache,Filter(collIPPOfflineCache, IPP_Id<>gallSearchResultsOnline.Selected.Id));
ClearCollect(tempcollIPPDetails,Filter(collIPPDetails, IPP_Id<>gallSearchResultsOnline.Selected.Id) );

 

//Complete the action by copying the temporary collection back to the source collection

ClearCollect(collIPPOfflineCache, tempcollIPPOfflineCache);
ClearCollect(collIPPDetails, tempcollIPPDetails);

 

 

juresti
Level: Powered On

Re: Remove() and RemoveIf() functions not working on iPhone

Hello, I am also running into this problem where the mobile device will remove two rows from my collections. I have tried it on android tablet and phone. On the computer, the remove function works correctly. The provided solution will do for me as well until this bug is fixed.
juresti
Level: Powered On

Re: Remove() and RemoveIf() functions not working on iPhone

I have tried the suggested solution and it did not solve the problem for me. Here is what I believe I have found. The table view with a column using as link can't be clicked from the mobile app properly causing it to click two or more rows and removing them. If you try to run a patch in a table column's OnClick event it won't work at all. It just doesn't click when using a mobile device. I avoided using tables / forms and used a custom gallery instead with controls such as buttons and toggles that can be clicked from the mobile device apps and that solved all the issues with patching / removing single record from collections in mobile devices. Note: None of these bugs exist running the app from a computer.