SPFx multi component solution issue

%3CLINGO-SUB%20id%3D%22lingo-sub-885923%22%20slang%3D%22en-US%22%3ESPFx%20multi%20component%20solution%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-885923%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20working%20on%20an%20SPFx%20solution%20with%20multiple%20components%20-%202%20webparts%20and%202%20extensions%20(listview%20commandsets).%26nbsp%3BUpon%20deploying%20the%20package%20to%20App%20Catalog%2C%20while%20the%20webparts%20seem%20to%20work%20fine%2C%20only%20one%20of%20the%20extensions%20is%20activated%20and%20not%20the%20other%20one.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3Eelements.xml%3C%2FSTRONG%3E%3C%2FFONT%3E%20has%202%20%3CFONT%20color%3D%22%23ff00ff%22%3E%3CCUSTOMACTION%3E%3C%2FCUSTOMACTION%3E%3C%2FFONT%3E%20elements%2C%20one%20for%20each%20extension%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000ff%22%3EClientSideInstance.xml%3C%2FFONT%3E%20has%202%20%3CFONT%20color%3D%22%23ff00ff%22%3E%3CCLIENTCOMPONENTINSTANCE%3E%3C%2FCLIENTCOMPONENTINSTANCE%3E%3C%2FFONT%3E%20elements%2C%20one%20for%20each%20extension.%3C%2FP%3E%3CP%3EBut%20still%20no%20luck%2C%20wonder%20what's%20missing.%20Appreciate%20any%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1045382%22%20slang%3D%22en-US%22%3ERe%3A%20SPFx%20multi%20component%20solution%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1045382%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F418028%22%20target%3D%22_blank%22%3E%40MeeraPan%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3Edo%20custom%20actions%20refer%20to%20the%20same%20list%20(registration%20type%20%2F%20registration%20id)%3F%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%0A%3CELEMENTS%20xmlns%3D%22%26lt%3Ba%20href%3D%22%3Ehttp%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%22%26gt%3B%0A%0A%20%20%20%20%3CCUSTOMACTION%20title%3D%22SPFxListViewCommandSet%22%20registrationid%3D%22100%22%20registrationtype%3D%22List%22%20location%3D%22ClientSideExtension.ListViewCommandSet.CommandBar%22%20clientsidecomponentid%3D%225fc73e12-8085-4a4b-8743-f6d02ffe1240%22%20clientsidecomponentproperties%3D%22%7B%26amp%3Bquot%3BsampleTextOne%26amp%3Bquot%3B%3A%26amp%3Bquot%3BOne%20item%20is%20selected%20in%20the%20list.%26amp%3Bquot%3B%2C%20%26amp%3Bquot%3BsampleTextTwo%26amp%3Bquot%3B%3A%26amp%3Bquot%3BThis%20command%20is%20always%20visible.%26amp%3Bquot%3B%7D%22%3E%0A%20%20%20%20%3C%2FCUSTOMACTION%3E%0A%0A%3C%2FELEMENTS%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIf%20yes%2C%26nbsp%3BI%20think%20you%20have%20to%20manage%20the%20business%20logic%20by%20considering%20only%20one%20custom%20action%2C%20from%20the%20point%20of%20view%20of%20the%20scheme%2C%20with%20more%20action%20(buttons)%20(i.e.%3A%20command_1%20or%20command_2)%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%40override%0Apublic%20onExecute(event%3A%20IListViewCommandSetExecuteEventParameters)%3A%20void%20%7B%0A%20%20switch%20(event.itemId)%20%7B%0A%20%20%20%20case%20'COMMAND_1'%3A%0A%20%20%20%20%20%20Dialog.alert(%60Clicked%20%24%7Bstrings.Command1%7D%60)%3B%0A%20%20%20%20%20%20break%3B%0A%20%20%20%20case%20'COMMAND_2'%3A%0A%20%20%20%20%20%20Dialog.prompt(%60Clicked%20%24%7Bstrings.Command2%7D.%20Enter%20something%20to%20alert%3A%60).then((value%3A%20string)%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20%20%20Dialog.alert(value)%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20break%3B%0A%20%20%20%20default%3A%0A%20%20%20%20%20%20throw%20new%20Error('Unknown%20command')%3B%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

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.

1 Reply
Highlighted

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="{&quot;sampleTextOne&quot;:&quot;One item is selected in the list.&quot;, &quot;sampleTextTwo&quot;:&quot;This command is always visible.&quot;}">
    </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