There has been a lot of talk about tokenization behavior with regards to the Server ribbon in SharePoint 2010. I hope that this blog post can help some of you that are running into problems using tokens.

In general, here are the tokens that are resolved and where they are resolved:

Location

ListUrlDir

ItemId

ItemUrl

RecurrenceId

SiteUrl

ListId

Source

SelectedListId

SelectedItemId

List View

Yes

No

No

No

Yes

Yes

Yes

Yes

Yes

List Form

Yes

Yes

Yes

Yes

Yes

Yes

Yes

No

No

Custom actions in SharePoint Foundation 2010 can be categorized in two ways: filtered and unfiltered custom actions. A filtered custom action is one that uses the RegistrationId and RegistrationType attributes, for example to target a specific list. An unfiltered custom action is one that does not use these attributes. Their behavior when handling URL tokens is different dependent upon the type of custom action being used to customize the Server ribbon.

The following table lists the tokens and how they’re resolved in different scenarios.

Type of Custom Action Location Web Parts {ListId} {ItemId} {SelectedListId} {SelectedItemId}
Unfiltered List View and List Forms Single and Multiple Not resolved Not resolved Resolved if selection is made from a List View Web Part Resolved if selection is made from a List View Web Part
Filtered List View Single Resolved Not resolved Resolved if selection is made from a List View Web Part Resolved if selection is made from a List View Web Part
Filtered List Form Single Resolved Resolved Resolved if selection is made from a List View Web Part Resolved if selection is made from a List View Web Part
Filtered List View Multiple Not resolved Not resolved Resolved if selection is made from a List View Web Part Resolved if selection is made from a List View Web Part
Filtered List Form Multiple Resolved Resolved Resolved if selection is made from a List View Web Part Resolved if selection is made from a List View Web Part

There are, however, two special cases when dealing with these URL tokens.

  • For non-Ribbon, unfiltered custom actions, {ListId} will be resolved in some cases (e.g. Location=Microsoft.SharePoint.StandardMenu and Group=SettingsMenu).
  • If a List View only has one Web Part in it, the SelectedListId will be resolved for both filtered and unfiltered custom actions.

I hope this helps clear up some of the confusion around the topic!