SharePoint – Update provider hosted apps lists without losing data

It’s been a while that we’ve been developing SharePoint Provider Hosted apps and one of the problems that happens most of the time is that you need update the app for SharePoint and add the new lists without lose any data from others existing lists.

Basically, if you publish one SharePoint Provider hosted app with a set of customs lists, and in the future, if you try update your app with more custom lists you have the option of this list to appear on your application:

  • One of these options, is to remove your app on your SharePoint Web and then re- install again.

On this situation, all data that the application been collecting along the time is removed and probably your customer needs to press the red bottom for call all firemen’s to help him to rescue the data.

On the other hand, the second option is to create in your application, the mechanism to ensure the new lists.

In my opinion, the best way for you to validate if some list was or wasn’t created into your SharePoint App, it is in Configuration/Settings View zone of your app because in this area, you can define app settings and validate if lists exist.  

To help you, I’ve created an extension based ListCollectionExtensions and the following code show you how you apply this:

This extension allows you to check if the list exist (if not, then creates the list)  and you have chance to add or not, more columns using string xml Field representation.

So now, I need just call the extension into your code.

 

 

I hope you enjoy. See you later. bye 😊

Leave a Reply