Question

I have a feature put together in Visual Studio 2010 that creates 3 external list instances. These get created just fine when the feature is activated, but upon deactivation they remain on the SharePoint site.

Is there any way to remove these list instances when the feature deactivates?

Was it helpful?

Solution

You need to be extremely careful. SharePoint does not delete lists by default because it does not want to destroy customer's data. If the customer has added data to the list or "re-purposed" it then they will be very angry when you destroy their data.

When you say "External List Instances" I assume you mean BCS External Lists. If so then your list will not contain any additional data but the list instance might have been customized by the user (View or Query).

If you are you really sure you need to destroy the list and any customizations it contains then I would suggest an SPFeatureReceiver and on FeatureDeactivating use the object model to find the list and delete it.

OTHER TIPS

Using the SPFeatureReceiver is the best way to remove the list on feature deactivation. I am assuming though that you want to remove the list on a development environment only? If so you could delete the list with a powershell script locally after the solution is redeployed, this can be automated in VS2010. This method will mean that the list removal is only on your enviroment and then there is no danger of deleting lists on a live environment.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top