I was working on upgrading a simple SharePoint application from SharePoint 2007 to SharePoint 2010. One of the components was a CustomAction feature that placed a menu item on a list’s toolbar. So I needed to migrate the CustomAction Xml to place the menu item on the SharePoint 2010 ribbon.
No big deal I thought.After a bit of work, I had the button created and showing up on the correct lists’ ribbons. After a few tests, I discovered that the only issue with the button was that the {ListId} token in the CommandAction element was not getting replaced with the list’s ID as it had in SharePoint 2007 (WSS 3.0 and MOSS 2007) and as it was supposed to (according to all of the documentation and articles I could find).
After a lot of digging around, I found an updated MSDN document showing new replace tokens for the CommandAction element, one of which was the {SelectedListId} token. I changed the {ListId} token to the {SelectedListId} token, re-deployed my feature Xml, and presto, it worked!
The new tokens for the SharePoint 2010 CommandAction element of the CustomAction element shown in the MSDN article are:
-
{RecurrenceId} – ID of a recurrent item (RecurrenceID).
-
{ListUrlDir} – Server-relative URL of the site plus the list’s folder.
-
{Source} – Fully qualified request URL.
-
{SelectedListId} – ID (GUID) of the list that is currently selected from a list view.
-
{SelectedItemId} – ID of the item that is currently selected from the list view.
I still don’t know why the {ListId} token did not work as it had with SharePoint 2007, but at least there seems to be a token that gives me the same information.If the {ListId} token is not working for you in SharePoint 2010, try changing it to the {SelectedListId} token.