In the previous blog here, we looked at how to deploy and install SharePoint Apps. Now let’s look at installing SharePoint Framework extensions – Listview command sets programmatically.
SharePoint CSOM
SharePoint Framework has three type of extensions that could be created – Application customiser, Listview command sets and Field customisers. In this blog, we will look at adding list view command sets programmatically.
Listview command extensions are actually custom actions installed in a library or list. Hence to activate it we will go to the library/list, find the installed custom actions, if not installed we will install the new custom action. Below is the code for that.
PowerShell
We could also use PnP PowerShell to add the Library extension onto a page using the code below
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$credentials = Get-Credential | |
Connect-PnPOnline "https://<your-tenant>.sharepoint.com/sites/<target-site>" -Credentials $credentials | |
## You can use the following PnP cmdlet | |
## ClientSideComponentId from Manifest.Json of the extension | |
Add-PnPCustomAction -Name "<CommandSetName>" -Title "<CommandSetTitle>" -Description "<Text>" -RegistrationId "101" -RegistrationType List -ClientSideComponentId "<Id from Manifest.json>" -Location "ClientSideExtension.ListViewCommandSet" |
Hence, above we saw how we could add extensions onto a library or list using CSOM or PowerShell
Happy Coding!!
Hi Asish
Thank you for your post. It’s quite helpful.
But in my case, I need one step back.
My App is installed. I can see that using AppManager(clientContext);
When I’m trying to get the app using,
var components = page.AvailableClientSideComponents();
it’s not getting, because it’s in [Apps you can add] state, not in added state.
How to achieve this condition.
I’m provisioning modern site, I want to add a Custom SPFX webpart into a newly added page.
Any help on this is much appreciated.
Thank you
anand
LikeLike
Easy.. here is the blog with details, let me know if need more information
LikeLike
Here is link – https://asishpadhy.com/2018/09/19/deploy-and-add-spfx-webparts-to-modern-pages-using-officedevpnp-csom-library/
LikeLike