SharePoint Framework Provision Assets

SharePoint Framework Provision Assets

Today, lets take up the topic ‘SharePoint Framework provision assets’. Basically I am referring to the basic building blocks of SharePoint such as:

  1. Create site columns
  2. Site content type
  3. Use SharePoint Framework – Provision List (Create List)

Create a SharePoint Framework project

Firstly, create a folder and an empty SharePoint Framework SpFx project. I have explained this in my previous posts SharePoint Framework SpFx Setup and SharePoint Framework SpFx Example.

I have created a folder and a project with the name – ‘provision-assets’.

Build the SharePoint feature to provision SharePoint assets

In the root folder, create a sub-folder called sharepoint. And under this create another folder called assets. Most noteworthy, the naming of these folders is important. Because,if we give any other names, the SharePoint framework will not be able to recognize it. Also, under the assets folder create two files elements.xml and another schema.xml. The folder structure should now look like:

Folder Structure

Furthermore, in the package-solution.json, we need to add a features property.

"solution": {
    "name": "provision-assets-client-side-solution",
    "id": "CFB58703-92FD-4FE6-A045-7CAD8728A5AD",
    "version": "",
    "features": [
        "title": "Provisioning SharePoint assets",
        "description": "Provisioning SharePoint assets",
        "id": "0FDE125A-CC04-40AE-829A-86027262D77B",
        "version": "",
        "assets": {          
          "elementManifests": [  
          "elementFiles": [
    "includeClientSideAssets": true

Also, ensure that you have a unique GUID for the features -> id attribute.

Now, we can go on populating the elements.xml and Schema.xml as per our requirement.

To add a Site Column:

	DisplayName="Number Of Pages"

Adding a Site Content Type:

<ContentType ID="0x0100B927FAD0B4C1421BB7BF128AEE37642A" Name="BookCT" Group="SPG" Description="Book Content Type" Inherits="TRUE" Version="0">
<FieldRefID="{f1fdf984-a58a-4be0-b81b-6a3191fc5fec}"DisplayName="Number Of Pages"Required="FALSE"Name="NumberOfPages"/>

Add a List:

<ListInstance CustomSchema="schema.xml" FeatureId="00bfea71-de22-43b2-a848-c05709900100" Title="Books" OnQuickLaunch="TRUE" TemplateType="100" Url="Lists/Books" Description="A List of Books"></ListInstance>

Note that we cannot add a list definition to SharePoint Online with this method. Because the ListTemplate element is not supported. However, with the ListInstance we can specify the CustomSchema parameter and provide a custom schema.xml.
We have already added the schema.xml to the elementFiles attribute in the package-solution.json.

I have customized the Schema.xml slightly to remove the default Item content type. Otherwise, it will show as the default content type instead of our custom content type. I have omitted the other parts of the file to save space. You can checkout the full source code for this app in my github at spfx-provision-assets

<List xmlns:ows="Microsoft SharePoint" Title="Books" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Books" BaseType="0" xmlns="" EnableContentTypes="TRUE">
<ContentTypeRefID="0x0120"/><ContentTypeRefID="0x0100B927FAD0B4C1421BB7BF128AEE37642A"Name="BookCT"Group="Custom Content Types"Description="My Content Type"Inherits="TRUE"Version="0"><FolderTargetName="Item"/></ContentTypeRef></ContentTypes>

Deploying the app

By now, I think you are already familiar with the deploying and testing the app. If not, please check out my previous posts SharePoint Framework SpFx Example and SharePoint Framework SpFx Setup

Leave a Reply

Your email address will not be published. Required fields are marked *