2

I am trying to create a custom action in SharePoint, and get it appear in the context menu (the 3 dots next to the item in the list).

I have tried all different combinations of location in elements.xml and ClientSideInstance.xml, however I can only get it to show in the tool bar above.

this is my elements.xml:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Title="HelloWorld"
        RegistrationId="100"
        RegistrationType="List"
        Location="ClientSideExtension.ListViewCommandSet"
        ClientSideComponentId="02d95d92-fde1-45a1-a428-941e8744d453"
        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>

According to this webpage: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/guidance/migrate-from-ecb-to-spfx-extensions

it says:

ClientSideExtension.ListViewCommandSet.ContextMenu: The context menu of the item(s).

ClientSideExtension.ListViewCommandSet.CommandBar: The top command set menu in a list or library.

ClientSideExtension.ListViewCommandSet: Both the context menu and the command bar (corresponds to SPUserCustomAction.Location="CommandUI.Ribbon").

but it doesn't seem to work.

The SharePoint site is a Communication site.

1 Answer 1

2

There are three places where you may need to set the Location property to get the commands to show in the list item context menu.

  1. Debugging: If you are debugging the extension (using gulp serve), you need to set the location in ./config/serve.json.

enter image description here

  1. Tenant-wide deployment: If you choose to automatically add the extension to all sites when you deploy the package containing the extension to the app catalog, then you need to set the location in ./sharepoint/assets/ClientSideInstance.xml.

enter image description here

This will ensure the appropriate item will be added to the Tenant Wide Extensions list in the app catalog site.

enter image description here

Please note that changes to ./sharepoint/assets/ClientSideInstance.xml may not update the item in the Tenant Wide Extensions list when you redeploy the package to the app catalog. You may need to manually edit the item in the Tenant Wide Extensions list so it reflects the changes you made to ./sharepoint/assets/ClientSideInstance.xml.

Please also note that it may take several minutes before the commands appear when you use tenant-wide deployment.

  1. "Traditional" deployment (i.e. not using tenant-wide deployment): If you choose not to automatically add the extension to all sites when you deploy the package containing the extension to the app catalog, then you need to set the location in ./sharepoint/assets/elements.xml.

enter image description here

When everything is configured properly, you should see the commands appear in both the command bar and the list item context menu.

enter image description here

enter image description here

1
  • Thanks for this, I thought I changed it in all these places, but in the end I did end up getting it working by doing a find and replace for the entire project.
    – Michael
    Commented May 22, 2022 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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