Adding Custom Actions to the List Item Menu in SharePoint 2010 Using SharePoint Designer 2010[Sharepoint中添加自定义菜单]
2011-01-18 14:04
1136 查看
http://www.endusersharepoint.com/2010/02/02/adding-custom-actions-to-the-list-item-menu-in-sharepoint-2010-using-sharepoint-designer-2010/
In SharePoint 2010, it is easier than ever to add custom actions that are
scoped to a specific list using SharePoint Designer 2010. So today, I am going
to walk you through the process.
In a related post on my
blog
, I showed you how to surface ULS logs using SharePoint
Designer 2010, an External Content Type, and an External List. We’re going to
use that list as our base for our custom action.
Our phony business case for this custom action is such – We are surfacing our
ULS logs into a SharePoint list, and want to collect feedback on specific log
entries for later consumption. We need to link to a form elsewhere in the site,
which we will pass a reference to the item in question, as a URL.
Note – the List Item Menu refers to the same thing as the Edit Control Block.
This is the context menu which is associated with all list items, available in
list views and list view web parts.
So, let’s open SharePoint Designer 2010, and navigate to our ULS Logs list,
and we’re going to select Custom Action > List Item Menu
from the Custom Action
button on the ribbon UI
Once we select that link, we are presented with the following form
We’re going to name our custom action Log Entry
Comment
, and give it a description as well. Now let’s scroll down.
You will see that we have 3 different types of actions we can associate with
this custom action…
We can
Navigate to a Form
for this list
We can Initiate a Workflow
Or, we can Navigate to a URL
We’re going to select Navigate to URL
, and enter in our URL,
and enter in our bogus URL, and pass a name/value pair of ItemURL={ItemUrl},
which was found by looking into the November 2009 version of the SharePoint 2010
SDK
OH NO! We can’t use it in Beta 2, which is the public beta we are running!
Ok, so I guess on the receiving end, we’ll need to fix it up in some other way.
So, we’ll just change our URL to pass a few things, and build the URL
ourselves.
http://www.grace-hunt.com/ULSLogComments?ItemURL={SiteUrl}/Lists/ULS
Logs/DispForm.aspx?ID={ItemId}
there, that should do the trick…
So, set your URL, and then give it a sequence number. This is the number in
which it appears in the list. Anything over 10000 is a good practice, so you do
not interfere with any other items in the list.
Then click OK
, and you now have a custom action, associated
with a list item, all without cracking open Visual Studio, deploying a package,
etc. etc.
You will now see it on the ULS Logs list dashboard page in SharePoint
Designer 2010
So, let’s go check out list… and there we have it, our custom action,
associated to the list item menu/edit control block, within our list!
And if we click it, we get an ugly, url encoded version
(http://www.grace-hunt.com/ULSLogComments?ItemURL=http%3A%2F%2Fsp2010dev%2D01/Lists/ULS
Logs/DispForm.aspx?ID=__cb40004300o4200b7983a57-53e7-de11-8ed4-000c29a9d0f1)
of:
http://www.grace-hunt.com/ULSLogComments?ItemURL=http://sp2010dev-01/Lists/ULS Logs/DispForm.aspx?ID=__cb40004300o4200b7983a57-53e7-de11-8ed4-000c29a9d0f1
Another cool thing, which you may notice, is that ALL list items have a
globally unique identifier in SharePoint 2010! YES! No more list item IDs
starting with 1, and going up from there.
In SharePoint 2010, it is easier than ever to add custom actions that are
scoped to a specific list using SharePoint Designer 2010. So today, I am going
to walk you through the process.
In a related post on my
blog
, I showed you how to surface ULS logs using SharePoint
Designer 2010, an External Content Type, and an External List. We’re going to
use that list as our base for our custom action.
Our phony business case for this custom action is such – We are surfacing our
ULS logs into a SharePoint list, and want to collect feedback on specific log
entries for later consumption. We need to link to a form elsewhere in the site,
which we will pass a reference to the item in question, as a URL.
Note – the List Item Menu refers to the same thing as the Edit Control Block.
This is the context menu which is associated with all list items, available in
list views and list view web parts.
So, let’s open SharePoint Designer 2010, and navigate to our ULS Logs list,
and we’re going to select Custom Action > List Item Menu
from the Custom Action
button on the ribbon UI
Once we select that link, we are presented with the following form
We’re going to name our custom action Log Entry
Comment
, and give it a description as well. Now let’s scroll down.
You will see that we have 3 different types of actions we can associate with
this custom action…
We can
Navigate to a Form
for this list
We can Initiate a Workflow
Or, we can Navigate to a URL
We’re going to select Navigate to URL
, and enter in our URL,
and enter in our bogus URL, and pass a name/value pair of ItemURL={ItemUrl},
which was found by looking into the November 2009 version of the SharePoint 2010
SDK
OH NO! We can’t use it in Beta 2, which is the public beta we are running!
Ok, so I guess on the receiving end, we’ll need to fix it up in some other way.
So, we’ll just change our URL to pass a few things, and build the URL
ourselves.
http://www.grace-hunt.com/ULSLogComments?ItemURL={SiteUrl}/Lists/ULS
Logs/DispForm.aspx?ID={ItemId}
there, that should do the trick…
So, set your URL, and then give it a sequence number. This is the number in
which it appears in the list. Anything over 10000 is a good practice, so you do
not interfere with any other items in the list.
Then click OK
, and you now have a custom action, associated
with a list item, all without cracking open Visual Studio, deploying a package,
etc. etc.
You will now see it on the ULS Logs list dashboard page in SharePoint
Designer 2010
So, let’s go check out list… and there we have it, our custom action,
associated to the list item menu/edit control block, within our list!
And if we click it, we get an ugly, url encoded version
(http://www.grace-hunt.com/ULSLogComments?ItemURL=http%3A%2F%2Fsp2010dev%2D01/Lists/ULS
Logs/DispForm.aspx?ID=__cb40004300o4200b7983a57-53e7-de11-8ed4-000c29a9d0f1)
of:
http://www.grace-hunt.com/ULSLogComments?ItemURL=http://sp2010dev-01/Lists/ULS Logs/DispForm.aspx?ID=__cb40004300o4200b7983a57-53e7-de11-8ed4-000c29a9d0f1
Another cool thing, which you may notice, is that ALL list items have a
globally unique identifier in SharePoint 2010! YES! No more list item IDs
starting with 1, and going up from there.
相关文章推荐
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- How to remove the ribbon tabs in list forms in SharePoint 2010
- Use Microsoft SharePoint Designer 2010 to customize the list view 3---Parameter and Filter
- Using the string repalce action in SharePoint workflow designer to send mail from mail template
- Use Microsoft SharePoint Designer 2010 to customize the list view 2
- SharePoint designer 2010编辑List的表单时出现错误:soap:Server was unable to process request. ---> Value does not fall within the expected range
- sharepoint ECMA using a custom contentType to creating a list in SubSite
- [转]Writing Custom Entries to the Audit Log in Windows SharePoint Services 3.0(如何记录自定义审核日志)
- SharePoint 2010: Create a Custom Page Layout for a Publishing Site using SharePoint Designer
- 【转载】Adding Validation to a Custom List Control in Sharepoint
- Use Microsoft SharePoint Designer 2010 to customize the list view 1
- add a custom action to a SharePoint list actions menu for a specific list or content type
- sharepoint 2010 页面添加footer方法 custom footer for sharepoint 2010 master page
- Custom Ribbon in SharePoint 2010 & which not wrok when migrate from 2010 to 2013
- SharePoint Development - Custom List using Visual Studio 2010 based SharePoint 2010
- sharepoint 2010 页面添加footer方法 custom footer for sharepoint 2010 master page
- How to hide my site and my document link in the right-top corner of sharepoint 2010
- sharepoint 2010 页面添加logo banner方法 custom banner for sharepoint 2010 master page
- sharepoint 2010 页面添加footer方法 custom footer for sharepoint 2010 master page