Hide start workflow menu
-
22-10-2019 - |
Question
I want to hide "start workflow" menu with hidecustomaction This example is from a sharepoint book.
<HideCustomAction Id="RemoveRibbonButton"
Location="CommandUI.Ribbon.Library.Actions.ConnectToClient">
</HideCustomAction>
"Start Workflow" has id="Ribbon.List.Settings.ManageWorkflows.Menu.Manage.Associate-Menu"
So I have tried:
<HideCustomAction Id="RemoveRibbonButton"
Location="CommandUI.Ribbon.List.Settings.ManageWorkflows.Menu.Manage.Associate-Menu">
</HideCustomAction>
What location is it?
Solution
Ribbon buttons cannot be hidden using HideCustomAction, at all. At least, I've tried this and it doesn't work.
You should use CustomAction for this purpose, with empty CommandUIDefinition elements, like this:
<CustomAction
Id="RemoveRibbonButton"
Location="CommandUI.Ribbon"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Styles" />
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
This approach was tested many times and works like a charm.
But in your particular situation, this method won't work. The point here is that Manage Workflows
is a SplitButton, and it's items are populated dynamically through the javascript. And the menu is hardcoded into javascript.
So, you can easily hide the whole Manage Workflows
SplitButton, passing "Ribbon.List.Settings.ManageWorkflows" to the CommandUIDefinition element location. But to hide one of menu items, you ought to do a lot of work.
Actually, you should replace OOTB Manage Workflows
SplitButton with your own, and write your own script, which returns the whole dynamic menu XML code.
Or, you can choose to refuse dynamic functionality, and deal with static menu approach - actually it is much easier and I recommend you to start with it, although I have the ready-to-use solution for dynamic menu.
The whole code:
<CustomAction Id="RemoveAddWorkflowMenuItem" Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.List.Settings.ManageWorkflows">
<SplitButton
Id="Ribbon.List.Settings.ManageWorkflows"
Sequence="30"
Command="ManageWorkflows"
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-112" Image16by16Left="-112"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-160" Image32by32Left="-416"
LabelText="$Resources:core,cui_ButManageWorkflow;"
MenuAlt="$Resources:core,cui_ButManageWorkflow;"
ToolTipTitle="$Resources:core,cui_ButManageWorkflow;"
ToolTipDescription="$Resources:core,cui_STT_ButListManageWorkflow;"
TemplateAlias="o2"
PopulateDynamically="false"
>
<Menu Id="Ribbon.List.Settings.ManageWorkflows.Menu">
<MenuSection DisplayMode="Menu" Id="Ribbon.List.Settings.ManageWorkflows.Menu.Manage">
<Controls Id="Ribbon.List.Settings.ManageWorkflows.Menu.Manage.Controls">
<Button Id="Ribbon.List.Settings.ManageWorkflows.Menu.Manage.EditSettings" Command="EditWorkflowSettings" MenuItemId="Ribbon.List.Settings.ManageWorkflows.Menu.Manage.WorkflowSettings.Menu" LabelText="Workflow Settings"/>
</Controls>
</MenuSection>
<MenuSection DisplayMode="Menu" Id="Ribbon.List.Settings.ManageWorkflows.Menu.CreateInSP">
<Controls Id="Ribbon.List.Settings.ManageWorkflows.Menu.CreateInSP.Controls">
<Button Id="Ribbon.List.Settings.ManageWorkflows.Menu.CreateInSP.CreateWorkflowInDesigner" Command="CreateWorkflowInDesigner" LabelText="Create a Workflow in SharePoint Designer"/>
<Button Id="Ribbon.List.Settings.ManageWorkflows.Menu.CreateInSP.CreateReusableWorkflowInDesigner" Command="CreateReusableWorkflowInDesigner" LabelText="Create a Reusable Workflow in SharePoint Designer"/>
</Controls>
</MenuSection>
</Menu>
</SplitButton>
</CommandUIDefinition>
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
Screenshot of the customized splitbutton:
P.S. If you often work with SharePoint Ribbon, I would recommend you to check out my open source project SharePoint 2010 Fluent Ribbon API, which simplifies ribbon creation and customization. It is completely free and licensed under Ms-PL.
OTHER TIPS
Note that the - separates the "id" from the "style", e.g. in the ribbon an action that renders using small icon plus text because of space will be called e.g. "Ribbon.Library.Actions.OpenWithExplorer-Medium"
According to http://msdn.microsoft.com/en-us/library/bb802730.aspx you should apparently use Location="CommandUI.Ribbon" and the further link tells you which id to use; so in theory e.g.
<HideCustomAction Location="CommandUI.Ribbon" HideActionId="Ribbon.Library.Actions.OpenWithExplorer" />
should have worked - if they supported it in ribbons like they do in menus, instead of the "empty custom action" workaround