Like the title says, I am trying to hide the "New Item" Button that is located in the Ribbon of a custom SharePoint 2013 list. I have already achieved this using CSS, but I am looking for a way to do this with Custom Actions. I have come across the HideCustomAction element, but have not yet made it work.
Has anyone done this before or does anybody know what I'm doing wrong? Is this even achievable with Custom Actions?
Here is what I have so far (315005 is the Template Id of my custom list):
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<HideCustomAction
GroupId = "Ribbon.ListItem.New"
HideActionId = "Text"
Id = "315005"
Location = "Ribbon.ListItem.New.NewListItem">
</HideCustomAction>
</Elements>
Ok, I have managed to hide all "New Item" Buttons with the following Custom Action:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="RemoveRibbonButton"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.ListItem.New.NewListItem" />
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
</Elements>
The only problem is now, I need to make this apply only to my custom list. So I have tried adding RegistrationType
and RegistrationId
properties, but the button isn't removed. Any ideas why?
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="RemoveRibbonButton"
Location="CommandUI.Ribbon"
RegistrationId="315005"
RegistrationType="List">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.ListItem.New.NewListItem" />
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
</Elements>
EDIT: I tested this on another custom list (315010) and it works with that list's Template Id. However, I have also a EvenReceiver that's attached to my 315005 list and it works. The EventReceiver also uses the TemplateId to reference the list it's attached to.