1

I am able to install/deploy an app to a sharepoint site using the code below

var appManager = new AppManager(context); var apps = appManager.GetAvailable(); var foundApp = apps.Where(a => a.Id == FeatureId).FirstOrDefault(); var installAppAsync = await appManager.InstallAsync(foundApp); 

However, one particular app needs to be tied to a specific document library when added to a site, how can I specify these parameters when installing the app?

1 Answer 1

2

If you're developing a custom command set for a list, after installing the SPFx package to the app catalog, you need to attach your command set to the target list with the code:

var list = clientContext.Web.Lists.GetById(listId); var customActions = list.UserCustomActions; var customAction = customActions.Add(); customAction.ClientSideComponentId = new Guid("Id of your command set"); customAction.Location = "ClientSideExtension.ListViewCommandSet.CommandBar"; customAction.Update(); clientContext.ExecuteQuery(); 

Please, note that your package must be either tenant-wide scoped or deployed to the app catalog of the target site collection.

2
  • There is a mixture of Apps that I need to add, some are ProviderHostedEventReceivers, others are commands like your example. Its the EventReceivers and the like that I need to add to the site. Commented Oct 9, 2019 at 7:32
  • You cannot attach event receivers with an app, you can do that programmatically only: sharepointnutsandbolts.com/2014/01/… Commented Oct 9, 2019 at 7:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.