Provision a SharePoint library with SPFx extensions

Overview

This Blog will help you on how to create a SharePoint library while provisioning SharePoint Framework extensions.

Introduction

The SharePoint Framework (SPFx) is a page and web part model that provides full support for client-side SharePoint development, easy integration with SharePoint data, and support for open source tooling. Here is the link to help you familiar with it. Reference Link -- https://docs.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview

Steps to be followed for this process:


1. Create a SharePoint Framework extension.

  • Create a new extension by running the Yeoman SharePoint Generator yo @microsoft/SharePoint
  • Fill the related information for the project
  • Install the related dependencies (npm install)
  • For more details refer the below Microsoft links:
    https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment
    https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/building-simple-cmdset-with-dialog-api
2. Create a SharePoint library which you need


  • Export the schema.xml for the library with the following link.
    $SiteUrl/_vti_bin/owssvr.dll?Cmd=ExportList&List={$libraryId}


Go to library settings, then you can see the library ID.
  • Update the schema.xml 
1. Remove all of the Name={xxx} attribute


2 Add two attributes (SetupPath=”pages\viewpage.aspx” WebPartZoneID=”Main”) to View.


3 Add two attributes (SetupPath=”pages\ form.aspx” WebPartZoneID=”Main”) to View

4 Remove the redundant path(TestLibrary/Forms/) of View and Form Url attribute.


  • Update your extension project.

1 Update package-solution.json file








2 Update elements.xml file




Add ListInstance



You can find the feature id and template type in the schema.xml file.



3. Add the updated schema.xml to sharepoint/assets folder





For more details:

https://docs.microsoft.com/en-us/sharepoint/dev/spfx/toolchain/provision-sharepoint-assets

  • Deploy extension to SharePoint App Catalog.

Build and package your solution by followed commands gulp bundle –production 

gulp package-solution –production 

Upload the packaged file to App catalog and publish it.


Install the extension to your site. The library will be created when the app installed.





















Comments

Popular posts from this blog

Introduction to Copilot in PowerApps

Still using Classic SharePoint Sites?

SharePoint Consulting Services in Canada & USA