Tuesday, July 17, 2012

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.

No comments:

Post a Comment