Question

I am creating a provider-hosted Sharepoint add-in that need to create some custom lists and content types during installation.

I have setup an Event Receiver to capture when the add-in has been installed (based on: https://msdn.microsoft.com/en-us/library/office/jj220052.aspx) and am now trying to work out the best way to define the list and field to be added.

One way is to just define each field in the code, but that seems difficult to maintain and could get ugly really fast.

Looking at the ListCreationInformation class being used to create the list, it has a CustomSchemaXml field. Is it possible to somehow get the text from inside the Schema.xml file that Visual Studio creates when adding a new List element (maybe by building it to the output directory and reading it using reflection)?

enter image description here

(ignore the temporary name)

Or, am I barking up completely the wrong tree? In which case is there a better way to define lists and content types to be installed with the application (also taking into consideration potential updates later on)?

Thanks

Was it helpful?

Solution

I ended up getting this working by first creating a Content Type with the columns I need, then creating a new List and assigning the content type columns to it.

The main trick is that once the add-in has been installed, the list doesn't appear to show up in the site content but is instead part of the app-domain and so can be accessed by changing the Start Page in the AppManifest to be Lists/<List Name>.

Hope this helps someone else.

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