5

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?

2 Answers 2

4

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.

1
  • Thanks Steve, you make a great point about being absolutely sure I want to remove the lists. This is my first delve into SP development and somehow I didn't think of that consequence ;) I was able to pull off what I needed to do after looking into SPFeatureReceiver. Thanks!
    – MattG
    Nov 1, 2010 at 15:50
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.