Forum Discussion
MeeraPan
Oct 01, 2019Copper Contributor
SPFx multi component solution issue
I'm working on an SPFx solution with multiple components - 2 webparts and 2 extensions (listview commandsets). Upon deploying the package to App Catalog, while the webparts seem to work fine, only one of the extensions is activated and not the other one.
elements.xml has 2 <CustomAction> elements, one for each extension,
ClientSideInstance.xml has 2 <ClientComponentInstance> elements, one for each extension.
But still no luck, wonder what's missing. Appreciate any help.
Hi MeeraPan ,
do custom actions refer to the same list (registration type / registration id)?
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="<a href="http://schemas.microsoft.com/sharepoint/" target="_blank">http://schemas.microsoft.com/sharepoint/</a>"> <CustomAction Title="SPFxListViewCommandSet" RegistrationId="100" RegistrationType="List" Location="ClientSideExtension.ListViewCommandSet.CommandBar" ClientSideComponentId="5fc73e12-8085-4a4b-8743-f6d02ffe1240" ClientSideComponentProperties="{"sampleTextOne":"One item is selected in the list.", "sampleTextTwo":"This command is always visible."}"> </CustomAction> </Elements>
If yes, I think you have to manage the business logic by considering only one custom action, from the point of view of the scheme, with more action (buttons) (i.e.: command_1 or command_2)
@override public onExecute(event: IListViewCommandSetExecuteEventParameters): void { switch (event.itemId) { case 'COMMAND_1': Dialog.alert(`Clicked ${strings.Command1}`); break; case 'COMMAND_2': Dialog.prompt(`Clicked ${strings.Command2}. Enter something to alert:`).then((value: string) => { Dialog.alert(value); }); break; default: throw new Error('Unknown command'); } }
Cheers,
Federico