UrlAction Tokens in SharePoint 2010

When creating CustomAction Elements, a number of tokens are available for use within the UrlAction Element in SharePoint 2010. The list of UrlAction tokens in SharePoint 2010 has grown ever so slightly (For a SharePoint 2007 reference, see UrlAction Tokens Of The CustomAction Feature).

Tokens

Key
Available in 2007
Available in 2010
Token Replacement
~site/ SPContext.Current.Web.ServerRelativeUrl
~sitecollection/ SPContext.Current.Site.ServerRelativeUrl
{ItemId} SPListItem.ID.ToString() or SPListItem["BdcIdentity"] (external data source)
{ItemUrl} SPListItem.Url
{SiteUrl} SPWeb.Url
{ListId} SPList.ID.ToString(“B”)
{RecurrenceId} SPListItem.RecurrenceID
{ListUrlDir} SPList.RootFolder.Url
{Source} Current Request Url

Microsoft.SharePoint.SPCustomActionElement.ReplaceUrlTokens

internal static string ReplaceUrlTokens(string urlAction, SPWeb web, SPList list, SPListItem item)
{
	if (string.IsNullOrEmpty(urlAction))
	{
		return urlAction;
	}
	if (item != null)
	{
		int d = item.ID;
		string str1 = d.ToString(CultureInfo.InvariantCulture);
		if (list.HasExternalDataSource)
		{
			str1 = item["BdcIdentity"] as string;
		}
		urlAction = urlAction.Replace("{ItemId}", str1);
		urlAction = urlAction.Replace("{ItemUrl}", item.Url);
		string recurrenceID = str1;
		if (!string.IsNullOrEmpty(item.RecurrenceID))
		{
			recurrenceID = item.RecurrenceID;
		}
		urlAction = urlAction.Replace("{RecurrenceId}", recurrenceID);
	}
	if (web != null)
	{
		urlAction = urlAction.Replace("{SiteUrl}", web.Url);
	}
	if (list != null)
	{
		urlAction = "{ListId}".Replace(Guid guid = list.ID, guid.ToString("B"));
		if (list.RootFolder != null)
		{
			urlAction = urlAction.Replace("{ListUrlDir}", list.RootFolder.Url);
		}
	}
	HttpContext current = HttpContext.Current;
	if (current != null && current.Request != null)
	{
		string rawUrl = current.Request.RawUrl;
		Uri contextUri = SPAlternateUrl.ContextUri;
		if (!string.IsNullOrEmpty(rawUrl) && null != contextUri)
		{
			string str2 = null;
			if (!SPUtility.StsStartsWith(rawUrl, "/"))
			{
				str2 = string.Concat(contextUri.GetLeftPart(UriPartial.Authority), "/", rawUrl);
			}
			else
			{
				str2 = string.Concat(contextUri.GetLeftPart(UriPartial.Authority), rawUrl);
			}
			urlAction = urlAction.Replace("{Source}", SPHttpUtility.UrlKeyValueEncode(str2));
		}
	}
	urlAction = SPUtility.GetServerRelativeUrlFromPrefixedUrl(urlAction);
	return urlAction;
}

Reference

SharePoint 2010 Site Templates: Operation is not valid due to the current state of the object

I recently ran into a strange error when attempting to use site templates (e.g. Save site as template) that had a “Site Pages” libary list view web part on the home page (e.g. Home.aspx). Any site created from these templates would have a corrupt home page.

The Error

The following is the home page of a site created from a template with a “Site Pages” list view web part on the home page.

The ULS error:

System.InvalidOperationException: Operation is not valid due to the current state of the object.
 at Microsoft.SharePoint.SPListItem.get_EffectiveBasePermissions()
 at Microsoft.SharePoint.WebPartPages.WikiEditPage.OnPreRender(EventArgs e)
 at System.Web.UI.Control.PreRenderRecursiveInternal()
 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The “Site Pages” library (note that Home.aspx is not present/visible):

The Fix

The fix is more a work-around. Do not put a “Site Pages” list view web part on the home page of any site you want to use as a template.

Using the SharePoint 2010 Information Worker Demonstration VM with VMware Step-by-Step

Geoff Varosky has a great post on his site titled Converting the SharePoint and Office 2010 Information Worker Virtual Machines to VMWare from Hyper-V. Geoff walks through using products such as WinImage and easyvmx to convert the 2010 Information Worker Demonstration and Evaluation Virtual Machine (SP1) from Hyper-V to a virtual machine compatible with VMware Player.

I’d like to present an alternative method, utilizing VMware Workstation and StarWind Free V2V Converter. Why? Because it’s nice to have alternatives.

(more…)

Tech-Ed North America 2011 SharePoint Sessions

All of the Tech-Ed North America 2011 SharePoint Sessions (and all of the other sessions) are available for streaming/download here.

Reference

Performance Optimization WordPress Plugins by W3 EDGE