We have to start with creating an empty element in the project. Then replace the text in the xml file with this:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Description="Approve Documents"
Title="Approve Documents"
Id="RibbonDocumentsManageApproveDocuments"
Location="CommandUI.Ribbon"
RegistrationId="10000"
RegistrationType="List"
Sequence="0"
xmlns="http://schemas.microsoft.com/sharepoint/">
<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Define the (UI) button to be used for this custom action -->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button Id="Ribbon.Documents.Manage.ApproveDocuments"
Command="{4E2F5DC0-FE2C-4466-BB2D-3ED0D1917763}"
Image32by32="~site/_layouts/Images/SharePoint-Z-Drive-Project/approve_document_32x32.png"
Image16by16="~site/_layouts/Images/SharePoint-Z-Drive-Project/approve_document_16x16.png"
Sequence="0"
LabelText="Approve Documents"
Description="Approve Documents"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<!-- Define the action expected on the button click -->
<CommandUIHandler Command="{4E2F5DC0-FE2C-4466-BB2D-3ED0D1917763}" CommandAction="javascript:window.open('http://www.bing.com/search?q='.concat(escape(document.title)))" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
<CustomAction
Description="Approve Document"
Title="Approve Document"
Id="EditControlBlockApproveDocument"
Location="EditControlBlock"
RegistrationId="10000"
RegistrationType="List"
ImageUrl="~site/_layouts/Images/SharePoint-Z-Drive-Project/approve_document_16x16.png"
Sequence="1101"
xmlns="http://schemas.microsoft.com/sharepoint/">
<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Define the (UI) button to be used for this custom action -->
<CommandUIDefinitions>
<CommandUIDefinition Location="EditControlBlock">
<Button Id="EditControlBlock.ApproveDocument"
Command="{F8C45D3A-A00D-4412-91BB-C49D75A36F3A}"
Sequence="1101"
LabelText="Approve Document"
Description="Approve Document"
TemplateAlias="o2" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<!-- Define the action expected on the button click -->
<CommandUIHandler Command="{F8C45D3A-A00D-4412-91BB-C49D75A36F3A}" CommandAction="javascript:window.open('http://www.bing.com/')" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
The first custom action is to add the button to ribbon bar in the document library.
The second custom action will add the button to the edit control block of an item.
No comments:
Post a Comment