Photo yesteryear Lex Sirikiat at Unsplash.
When automating Groups provisioning as well as configurations to a greater extent than or less configurations cannot hold upwardly achieved using app-only tokens, but convey to hold upwardly performed yesteryear a grouping owner.
Examples of this are setting the grouping logo or enabling Microsoft Teams for a group. This is where SharePoint Framework application customizers come upwardly inwards handy.
The thought is to run a slice of JavaScript 1 time an possessor enters the grouping site for the commencement time, as well as thus take the application customizer 1 time run, every bit it’s non needed anymore.
I wrote a sample customizer for this which yous tin honour at the PnP sample repository on GitHub.
In the sample I banking concern check if the user accessing the site is a site admin (group owner), as well as if thus run a slice of code.
let isSiteAdmin = this.context.pageContext.legacyPageContext.isSiteAdmin; if (isSiteAdmin) { this.DoWork(this.properties.property); }
A amend approach is to specify the needed rights for a user for the extension to charge inwards the commencement house – a proficient one-time custom activity feature. By setting the extension to charge if a user has ManageWeb rights, it volition effectively run for grouping owners as well as non members. This allows us to take the banking concern check inwards the actual code – or yous tin proceed it if yous want. The proficient component is that nosotros cut back loading of script which is non needed.
Below is a sample PnP provision template to install the application customizer.
<?xml version="1.0"?> <pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2017/05/ProvisioningSchema"> <pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.19.1710.0, Culture=neutral, PublicKeyToken=null" /> <pnp:Templates ID="CONTAINER-TEMPLATE-ENABLE-TEAMS"> <pnp:ProvisioningTemplate ID="TEMPLATE-ENABLE-TEAMS" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite"> <pnp:CustomActions> <pnp:SiteCustomActions> <pnp:CustomAction Title="EnableTeamsApplicationCustomizer" Name="EnableTeamsApplicationCustomizer" Location="ClientSideExtension.ApplicationCustomizer" ClientSideComponentId="fa80f680-bda9-4c15-a8fe-4e86be0bf593" Rights="ManageWeb" ClientSideComponentProperties="{"autoCreate":"{parameter:AutoCreate}"}" /> </pnp:SiteCustomActions> </pnp:CustomActions> </pnp:ProvisioningTemplate> </pnp:Templates> </pnp:Provisioning>
Summary
When creating SPFx customizers which are non needed yesteryear everyone, yous tin optimize loading times yesteryear specifying which access correct is needed for the customizer to charge inwards the commencement place.
You tin honour a listing of all access rights at https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx
Thanks for reading : Optimize Loading Of Run-Once Application Customizers Inward Sharepoint Framework For Run 365 Groups