cancel
Showing results for 
Search instead for 
Did you mean: 

Command to explicitly drop a collection in PowerApp script

I would like to be able to delete a collection explicitly in a Power App script. This would permit me to be able to "reset" a collection easily during development, and to remove a collection after it had served its purpose.

 

A call such as DeleteCollection(collectionName) or DropCollection(collectionName) would be useful.  This call would apply to in-application collections only.  Calling this function on a SharePoint List, or other persistent store should result in an error.

 

The return type of the function should be a Boolean value with true indicating that the collection had been deleted.  Further references to a Deleted collection would cause error conditions to be raised.

Status: New
Comments
Regular Visitor

I think you are little bit confused to how collections work. 

 

To create a collection, you simply use Collect or ClearCollect to a collection name of your choice. 

 

Collect(CollectionName, {Value: BarcodeScanner.Value})

 

To delete items in a collection you can use Clear or ClearCollect 

 

To remove / drop / delete a collection all you need to do is remove any references to it, so any place you have put Collect etc, just remove it, then exit the app, ensuring it is fully closed the collection will then no longer exist. 

 

This is because variables are created implicitly, as and when they need to you do not need to declare and you do not need to delete, dispose of them either. 

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-variables#types-of-variabl...

 

PS I had collection stuck in an app once that was collecting images, I found that I had accidently placed a collect on the OnVisible property for a screen I had duplicated a few times, very annoying. Check your app.

Advocate II

I get it that you just have to delete all references to it, but when you get into a larger app with lots of screens and hundreds of controls, it can be difficult to find where a collection is to delete its reference.  It underscores the importance of documenting use of variables, collections, etc. as you build the app.  But it would sure be nice to have a 'search' for some of these things.

Frequent Visitor

I agree that a delete collection command would be very helpful. The clear command will only delete the values in the table (the column headers still exist). If you want to reuse the collection for a different table, you'll have all these extra columns that will cause issues.

Responsive Resident

I would love the ability to completely delete a collection from the app. When a new Collect action is ran, this should remake the collection.

Frequent Visitor

This is super frustrating!!

 

  1. You can't edit collection columns without removing all the references
  2. There's no way to quickly FIND all the references to a given collection.

Microsoft, you gotta give us one or the other!  The workflow here is terrible!

Advocate IV

@Dalmasca: I entirely agree.  Furthermore, it's not like providing traceable information on initialisation and usage is foreign to the PowerApps Development Team.  Indeed, if you look at the menu item View>Collections' sibling View>Variables, you get details for each Variable when you drill down, you can see where a variable is defines, where the variable is used, and even "indirect" usages.

 

I spent a frustrating half day or so, when I mistakenly used different cases to create and use a collection.  It took a lot of time to eventually locate the incorrect collection instantiation "ArtWorkCatalogue" and remove references to it in favour of "ArtworkCatalogue".  Even with the support that you see with variables, it's often easier to locate the position of an object reference in a big lump of code by copying & pasting the code out to an external editor, and using that editor's find functionality to find the variable's reference.  This messy procedure also works for collections!

 

Microsoft,  please provide the same level of detail for collections (locations of initialisation and usages) as you have successfully managed to provide for variables.

Frequent Visitor

It doesn't even have to be a command. Just give a Delete button in the Collections UI so the app forgets that table structure until it runs into a Collect or ClearCollect command for it again.

 

I think Microsoft envisions collections as this runtime only thing that's easy to clear, but not having any name management system makes this incredibly unwieldy.  If I rename the collection where it's first created, how do I track down the 100s of references to it?

 

Likewise, DropColumns is a band-aid command for the actual issue. If the collection gets [Clear]Collected again somewhere after the DropColumns, the column you were trying to remove could be re-added!