Add custom action with add-pnpcustomaction

Contributor

Hello,

I'm trying to hide the delete button in SharePoint Online list ribbon; I tried with custom action and powershell but I'm blocked (see SPO custom action to hide delete button - Microsoft Tech Community ).

 

With other research I find that, maybe, is possible to add a custom action with the powershell cmdlet add-pnpcustomaction of Pnp.PowerShell module; I have seen the syntax of the cmdlet but I don't understand some thing; I have a list, only a SPO list, where I want to apply the custom action: is it possible?

Say I have the mytenant.sharepoint.com/sites/testsite where I have some lists, but I want to hide the delete button in the mytestlist: how to reference it in the command?

 

From some sample found online and also from the documentation sample I write something like this:

 

Connect-PnPOnline -Url "https://mytenant.sharepoint.com/sites/testsite" -Interactive
$cUIExtn = "<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.ListItem.Manage.Delete"" /></CommandUIDefinition></CommandUIDefinitions></CommandUIExtension>"
Add-PnPCustomAction -Name 'HideDeleteButton' -Title 'HideDeleteButton' -Location 'CommandUI.Ribbon' -RegistrationType List -Sequence 10000 -RegistrationId 101 -CommandUIExtension $cUIExtn

 

But, my 2 questions are:

  1. is it correct
  2. how or where reference the list?

Any help is appreciated.

 

--

Regards

 

0 Replies