When I Remove an item from a data source and collect the result in a collection, the collection contains the items remaining in the data source but not the deleted item.
Is this really the intended behaviour? It seems bizarre at best since in any case only up to 500 records will be returned, so this is completely useless. Much better to return the list of removed items, so that we can check that the operation has completed correctly.
Here is the code:
ClearCollect(MyReturnedItems, Remove(MySource, MyItem))
Even more bizarre is that RemoveIf does the same thing, making it impossible to check what records have been actually removed.
Any clarifications form the PowerApps team would be welcome.
Inverting the formula worked for a quick test I just ran. Does this work for you?:
I appreciate that the result of your formula is that MyReturnedItems contains the item that you wanted to delete.
However, there is no indication as to whether this item was really deleted or not. Your formula will return the item even if it is not actually deleted, even if there is no internet connection.
That is why it is important to collect the result of Remove (and RemoveIf and Patch) in a collection to be able to confirm to the user that the operation has completed successfully.
This is particulalrly important now that PowerApps has significant bugs in connecting to data sources like Azure SQL Database and SQL Server.
Thanks for the feedback.
I think the issue here should be related with the Delegation.
Remove and the Removeif function would return the modified data source as a table, but those two functions both do not support delegation.
Remove and RemoveIf return the modified data source as a table.
When used with a data source, these functions can't be delegated. Only the first portion of the data source will be retrieved and then the function applied. The result may not represent the complete story. A blue dot will appear at authoring time to remind you of this limitation and to suggest switching to delegable alternatives where possible. For more information, see the delegation overview.
Adding the function reference:
Could you please clarify how we can verify if a Remove or RemoveIf operation has actually worked?
With a Patch this is done by looking at the returned records, but this does not seem possible with Remove or RemoveIf.
If the intention is to verify that the Remove or RemoveIf operation has worked, maybe you could accomplish this by calling the Errors function? If this returns no rows, I think we can probably assume that the operation worked.
As a quick test, I created a set of related tables.
I then called the following function to remove all the records in TestTable.
Afterwards, the Errors function reported errors on record IDs 3 and 4 due to referential integrity, which is what I'd expect.
I understand that what you want is positive confirmation of the records that were deleted. But in the absence of this feature, perhaps the Errors function can be of some help?
Hi @timl, thanks for the feedback.
You are correct, I would like to have positive confirmation and the number of records deleted. In its absence I guess we could use the Errors function.
Much easier/logical to just return the deleted records. Unclear to me why such a design choice was made.
Hi all, if you are interested I have created this idea.
Fill out a quick form to claim your user group badge now!
Find out where you can attend!
Features releasing from October 2019 through March 2020
Learn how to build the business apps that you need.