How to add a new "CustomAction" in ECB for a specific list
-
Tuesday, June 05, 2007 2:54 PMHello,
I would like to add a new custom action in the items dropdown menu of a specific list.
This code in my elements.xml file works fine but it affects all the custom lists of my portal :
Code Snippet<CustomAction Id="MyApp.ItemToolbar"
GroupId="MyApp"
RegistrationType="List"
RegistrationId="100"
Location="EditControlBlock"
Sequence="100"
Title="My custom action for this item"
ImageUrl ="/_layouts/MyApp/myicon.gif">
<UrlAction Url="/_layouts/MyApp/EditAppItem.aspx?ID={ItemId}"/>
</CustomAction>
I don't want this custom action in the other subsites and in the other custom lists !
Can you help me ?
Answers
-
Friday, June 08, 2007 7:04 PM
Instead of creating the feature to associate with all custom lists, you want to create the feature to only work with specific types of lists? Lists that you create? Then you'll need to associate the feature with your list type instead of the built-in list types.
For this, you'll need to create a feature with (at least) two elements: one to create a new List Template with a unique type, and one to create the custom ECB item that's activated for this unique type.
If you copy the CustomList feature to a new feature, then you can start here.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="MyCustomList"
Type="ListTemplateType"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="My Custom List"
Description="My Custom List"
Image="/_layouts/images/itgen.gif"/>
</Elements>For the ListTemplateType field , choose a unique identifying integer (different that what's listed below)
Code Snippetpublic 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,
}Finally, for your custom action, use the ListTemplateId. This will allow the ECB item to only appear in these list types. If you create additional lists based on this template, these lists will also have the custom ECB item appear.
Code Snippet<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Litware.MyCustomList"
RegistrationType="List"
RegistrationId="ListTemplateType"
ImageUrl="/_layouts/images/GORTL.GIF"
Location="EditControlBlock"
Sequence="300"
Title="View Additional Information" >
<UrlAction Url..." />
</CustomAction>
</Elements>
All Replies
-
Wednesday, June 06, 2007 12:38 PMAny idea ?
Could you tell me if what I'm expecting to do is possible ? -
Friday, June 08, 2007 7:04 PM
Instead of creating the feature to associate with all custom lists, you want to create the feature to only work with specific types of lists? Lists that you create? Then you'll need to associate the feature with your list type instead of the built-in list types.
For this, you'll need to create a feature with (at least) two elements: one to create a new List Template with a unique type, and one to create the custom ECB item that's activated for this unique type.
If you copy the CustomList feature to a new feature, then you can start here.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="MyCustomList"
Type="ListTemplateType"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="My Custom List"
Description="My Custom List"
Image="/_layouts/images/itgen.gif"/>
</Elements>For the ListTemplateType field , choose a unique identifying integer (different that what's listed below)
Code Snippetpublic 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,
}Finally, for your custom action, use the ListTemplateId. This will allow the ECB item to only appear in these list types. If you create additional lists based on this template, these lists will also have the custom ECB item appear.
Code Snippet<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Litware.MyCustomList"
RegistrationType="List"
RegistrationId="ListTemplateType"
ImageUrl="/_layouts/images/GORTL.GIF"
Location="EditControlBlock"
Sequence="300"
Title="View Additional Information" >
<UrlAction Url..." />
</CustomAction>
</Elements> -
Monday, June 11, 2007 9:23 AMThank you very much for the tip and for the lists template types !
-
Tuesday, July 24, 2007 12:47 PM
That's exactly what I want to do.
However, I have already my custom list created.
Is there another way for defining a custom action for a custom list that already exist without creating a new one with a list template please ?
Thanks in advance.
-
Thursday, September 27, 2007 10:11 AMHi there,
Does it mean that we have to include CustomAction and ListTempalte at the same time like this?
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="508EEC48-AD9B-4b6c-9163-4A0B64499F5A"
RegistrationType="List"
RegistrationId="20"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1002"
Title="Create PR Form"
Description="Create Purchase Request Form based on selected items."
ImageUrl="_layouts/images/CreatePRForm/CreatePRForm.gif">
<UrlAction Url="~site/_layouts/CreatePRForm/CreatePRForm.aspx?list={ListId}"/>
</CustomAction>
<ListTemplate
Name="SimpleList"
DisplayName="Simple List"
Type="20"
Description="This is my simple list."
BaseType="0" OnQuickLaunch="TRUE"
SecurityBits="11" />
</Elements>
Please advise, thank you. -
Monday, October 01, 2007 6:38 PM
You're not absolutely required to do so, but from a feature perspective, it makes much more sense to tie in the list template and custom action together into one feature. That way, you know that, if the feature is activated, both the list template and the custom action are activated (vice versa if feature is deactivated).
-
Saturday, October 06, 2007 12:22 PM
Hi abram,
my name is raghavendra and i am working for one software company. and i need help in creation some custom feature.I have seen u r reply in microsoft blog on creating "CustomAction" in ECB for a specific list , it was very good and suits my requirement. what my reauirement is i need to add one item in ECB of one perticular list. u geiven some solution like create one list template and apply this feature to that type of lists only. but i already created one list using a custom list template called "resource_request". now how can get the feature to that list only. i am in very urgent need.
i will give u my requirement in breif:
1) there is one list named "Resource Request" in my site. this list is created from list template called " resource_request".
2) now i need to add custom feature to the list "Resource Request" so that one option called "reopen request" in the ECB of the items of the list.
3)if the user clicks on this "reopen request" , i need to update correspanding item in list called "TcgTaskList" .
please help me out of this issue. i am new to moss 2007. my delivery date is tomarrow that's why i am mailing to u r personal mail id.thanks in advance .
-
Saturday, October 06, 2007 1:31 PM
There have been a number of questions about adding a custom action to a list that's already instantiated, specifically with a ListTemplateId that is not unique. As far as I know, there is no way of adding a Custom Action properly to lists that do not have a unique ListTemplateId. You can, of course, but the custom action will appear in all lists that share the ListTemplateId. You also cannot change the ListTemplateId, for it is a read-only property set at instantiation.
-
Saturday, October 06, 2007 3:22 PM
Hi,
thanks for u r quick response. I checked in the ListTemplate Gallery. in that gallery the ID of my ListTemplate is showing as "2" . so now can i use this ID in the custom action tag like:
<CustomAction Id="508EEC48-AD9B-4b6c-9163-4A0B64499F5A"
RegistrationType="List"
RegistrationId="2" ------ here "2" is my list template id.if i go like this can i get result.
-
Saturday, October 06, 2007 5:40 PM
Hi abram,
i followed the process u told . i created a feature to add a custom list template with coding of
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="MyCustomList"
Type="1234"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="My Custom List"
Description="My Custom List"
Image="/_layouts/images/itgen.gif"/>
</Elements>it is successfully installed.
but problem in i am getting an error while creating a list using this list template. the error i am getting is :
"Exception from HRESULT: 0x81070201" , can i know what is the reason and how to solve this.
even i tried by changing the value of "Type" in "List template" tag.
-
Tuesday, April 01, 2008 9:36 AM
Hi Abram, thank you for your post.
I 've followed the perecdent steps and I have got this message : Exception from HRESULT: 0x81070201
I'd like to know what you mean by <CustomAction
thank you very much.
Id="Litware.MyCustomList" -
Wednesday, February 11, 2009 3:10 AMId is used to distinguish the menu item, you can have your own defined name.
-
Monday, April 13, 2009 12:13 PM
Hi Abram,
Thanks for your guidelines but it will be great if you could post the complete code like what's need to be included in Feature.xml, Elements.xml, etc. so for anybody is easier to integrate the custom actions to a specific list.
Shaf -
Wednesday, April 15, 2009 5:57 AMhi,
I have written a Blog Explaning "How Create a Custom Action Specific to a List "
http://mnish.blogspot.com/2009/04/create-custom-action-specific-to-list.html
Check it out and Let me know.
regards
Manish -
Friday, April 23, 2010 9:36 AM
Thanks a lot Brian. I was having everything correct except for the ListTemplate Type. It wasn't unique. Thanks a lot again.
Regards,
Heramb
-
Friday, April 23, 2010 11:17 AM
If your using Content Types you can use the ID of the content type for that list, e.g.
<CustomAction ID="CustomAction1" RegistrationType="ContentType" RegistrationId="0x0120006C5De765F3287FF76R" ...
-
Wednesday, November 10, 2010 11:57 AM
hi
thanx for the solution.
Can i use the same approach for my document library?
i have multiple document libraries and i want to have ECB menu for document library created by me only.
Is it possible? please guide.

