Saturday, April 4, 2009

Creating ECB menu for specific list or document library

Hi All,

Many times requirement comes like we want to have a ECB menu item but for specific list or specific document library only not for all lists or not for all document library.

Let me give you very simple and short solution.

When you are creating your list or document library. Just create unique TemplateType in your elementmenifest.xml file.

let's say "100110" or any unique number which is not there in this list.

public enum SPListTemplateType
{
InvalidType = -1,
GenericList = 100,
DocumentLibrary = 101,
Survey = 102,
Links = 103,
Announcements = 104,
Contacts = 105,
Events = 106,
Tasks = 107,
DiscussionBoard = 108,
PictureLibrary = 109,
DataSources = 110,
WebTemplateCatalog = 111,
UserInformation = 112,
WebPartCatalog = 113,
ListTemplateCatalog = 114,
XMLForm = 115,
MasterPageCatalog = 116,
NoCodeWorkflows = 117,
WorkflowProcess = 118,
WebPageLibrary = 119,
CustomGrid = 120,
DataConnectionLibrary = 130,
WorkflowHistory = 140,
GanttTasks = 150,
Meetings = 200,
Agenda = 201,
MeetingUser = 202,
Decision = 204,
MeetingObjective = 207,
TextBox = 210,
ThingsToBring = 211,
HomePageLibrary = 212,
Posts = 301,
Comments = 302,
Categories = 303,
IssueTracking = 1100,
AdminTasks = 1200,
}

And when you create your CustomAction for ECB, just make sure RegistrationID should match with your unique ID of TemplateType of your list.

<CustomAction
Id="CC5EA7DE-CF2E-49ca-9629-1DAB00A06700"
RegistrationType="List"
RegistrationId="100110"
Location="EditControlBlock"
Sequence="333"
Title="Send to custom page">
<UrlAction
Url="{SiteUrl}/_layouts/MyPage.aspx?List={ListId}&amp;ID={ItemId}"/>

That's it. you are done with your task. now you will have ECB item only for your specific list or specific document library.

Thank you

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com