SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 1k forks source link

How do we change the feature scope for an SPFx extension? #649

Closed chrisobriensp closed 7 years ago

chrisobriensp commented 7 years ago

Category

Expected or Desired Behavior

When creating an SPFx extension (e.g. application customizer), I expected to be able to change the feature scope when the feature is defined in package-solution.json. The default is a site/web scoped feature, but sometimes we may want a site collection-scoped feature.

Observed Behavior

There is no "scope" property of the feature node, and adding one makes the file fail to be validated against schema in the bundling/build process. The following error is observed:

ERROR: Error parsing file 'package-solution.json' (#/solution/features/0) Additional properties not allowed: scope

Steps to Reproduce

  1. Create an application customizer using the steps outlined in the documentation at https://dev.office.com/sharepoint/docs/spfx/extensions/get-started/build-a-hello-world-extension.
  2. Add a "scope" child to a feature node in package-solution.json.
  3. Run gulp serve.

Here's an image which shows what I expected to do to change feature scope:

image

Can this be done? If so, how?

Thanks!

COB.

VesaJuvonen commented 7 years ago

This is not currently supported. All SPFx solution features are always scoped to 'Web' scope. We are though looking into releasing additional switches for the developers, which can be used to push out the SPFx solution to be available cross the site collections in the tenant as long as it's installed on the app catalog. You'd still need to associate the extension to be used in the site collection, but you do not need to install SPFx solution specifically to the sites.

This means that from the deployment perspective, scenario or steps would be following.

  1. Deploy your package to app catalog with specific configuration to enable that in the site collections - If it's a web part, it will be available immediately in the web part picker
  2. If it's an extension, you'll need to still associate the right ClientComponentId to specific location or to FIeld object
  3. You'll use remote provisioning techniques to set the Extension instance on the specific object

In your example case, you are building an ApplicationCustomier - so the process would be following to enable that cross specific or all sites.

chrisobriensp commented 7 years ago

Hey Vesa,

OK, that works! I don't mind it being a separate thing to do the association/binding, and there's a lot of control that comes it with it being done that way.

Will PnP XML schema be extended to support this?

Cheers,

COB.

VesaJuvonen commented 7 years ago

Yes - PnP 2017-05 PnP provisioning schema supports this. The engine has not yet been updated to match this requirement due to resource constraints, but coming soon as well. Since we will be however taking a break during July on PnP releases, engine update will be available from August 2017 release forward.

chrisobriensp commented 7 years ago

Great, thanks Vesa. Yes, I see the bits of documentation related to this in the 2017-05 schema (e.g. https://github.com/SharePoint/PnP-Provisioning-Schema/blob/master/ProvisioningSchema-2017-05.md#clientsidepages)

Good news all round, thanks!

Cheers,

COB.

wobba commented 7 years ago

@VesaJuvonen You say the engine has not been updated to associate global apps, but are you implying the code/logic behind this is available? Or is backend and PnP wrapper code targeted for August both? If API's are there to deploy to app catalog and associate to a web today I'd be thrilled :) Having it in PnP is nice and preferrable to me, but not a showstopper :)

VesaJuvonen commented 7 years ago

@wobba - Globally deployed apps/SPFx solution will be soon available with SPFx update for both server and client side. PnP templating does also support associating ClientSideComponentId with the latest schema for the sites, but you can absolutely use also native CSOM to get this completed. Steps to complete the scenario:

  1. Get SPFx update available and out
  2. Associate ClientSideComponentId with remote APIs for the needed objects in site collections - can be CSOM, REST, PnP Templates etc.

We'll obviously announce the global deploy option across different channels when it's available.

wobba commented 7 years ago

Nice :) The association to add oob parts I have allready tried :) And when you fill the deploy gap, that will be huge for the app/add-in model indeed. You guys are just kicking ass making it fun to create solutions for customers.

himanjanpati commented 6 years ago

Hello @chrisobriensp, can you please let me know how can i staple my extension through out all my site collections after i deploy that inside my app catalog? Can i get the extension in all my site collection though out my tenant?

frankchen76 commented 6 years ago

As @VesaJuvonen mentioned, you can use CSOM, REST or PnP to programmatically associate ClientSideComponentId with the site collection you want.

Rainson12 commented 6 years ago

@VesaJuvonen Is there a sample on how to associate my spfx extension to a site collection instead of only a web? Add-PnPCustomAction only adds it to a web scope..

VesaJuvonen commented 6 years ago

Few things.

anupam-ujjwal commented 6 years ago

@VesaJuvonen Is it possible to control to activation of features inside the feature framework ? Currently whenever a new app is added in a site, the corresponding feature automatically gets activated resulting in creation lists & libraries. I want to activate only on demand or based on the my requirements. This is a very basic requirements and is always available in earlier packaging (WSPs).

frnk01 commented 5 years ago

@VesaJuvonen Any update on the centralized control for extensions?

freekbe commented 5 years ago

I'm struggling to get my ListViewCommandSet loaded on all sites in a site collection. I think I followed the steps described in the previous posts correctly:

The ListViewCommandSet only gets loaded correctly on the root site of the site collection. On the subsites there is the following error message: Failed to loadCommandSet, id: 925aa26d-90ee-4cf7-8246-a38d53733036, error: Error: ***Manifest not found for componentId "925aa26d-90ee-4cf7-8246-a38d53733036". The ID mentioned in the error message is the correct one, the one that is registered in the manifest file.

Is there something else I need to do?

wobba commented 5 years ago

@freekbe try adding the app on your subsites as well, as apps are web scoped.

freekbe commented 5 years ago

@wobba Adding the app to the subsites solves this problem. But that is exactly what I want to avoid. The idea is to have the CustomAction activated on SiteCollection level so it is automatically available on all current and future subsites. From the previous comments I understood that this is possible by registering the CustomAction through code on the correct scope.

freekbe commented 5 years ago

I got it work! The missing piece of the puzzle is that you need to create a "Tenant-Scoped" solution.

wobba commented 5 years ago

@freekbe sure..that helps if you want it on all sites in your tenant :) didn’t get that from your question.

msft-github-bot commented 4 years ago

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues