1

I have created a ListView command set extension using SPFx and upload it in the app catalog. Now I want to install this extension for only particular sites.

I tried adding it as a custom action but it is not working.

Any help would be appreciated.

CustomActionEntity ca = new CustomActionEntity
                {
                    Title = "HelloWorld",
                    RegistrationId = "101",
                    RegistrationType = UserCustomActionRegistrationType.List,
                    Location = "ClientSideExtension.ListViewCommandSet.CommandBar",
                    ClientSideComponentId = spfxExtensionGlobalHeaderId,
                    ClientSideComponentProperties = "{"sampleTextOne":"One item is selected in the list.", "sampleTextTwo":"This command is always visible."}"
                };

         currentWeb.AddCustomAction(ca);
6
  • how did you tried to add it? Like we add any other app from Site Content? – Litt Spector Sep 11 '19 at 12:53
  • Also, please add the error you are getting. – Litt Spector Sep 11 '19 at 13:00
  • i am not getting any error but the command is not visible in the command after executing the code. – Mahesh kumar Chiliveri Sep 11 '19 at 14:24
  • Added code snippet used for adding as custom action. – Mahesh kumar Chiliveri Sep 11 '19 at 14:25
  • Did you try by adding the package manually in app catalog? – Litt Spector Sep 12 '19 at 10:58
0

I have successfully installed the extension using PnP App manager class.

AppManager appManager = new AppManager(clientContext);
var apps = appManager.GetAvailable();
foreach (var app in apps)
{
if (app.Title == "List View Command Set")
{
    appManager.Install(app);
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.