Dynamics CRM 2011 Portal Development – CrmSiteMap Expression

Dynamics CRM 2011 Portal Development

CrmSiteMap expression

More information regarding to ASP.NET Site Maps and SiteMapProvider Class

CrmSiteMap expression require ASP.NET sitemap feature enabled and Microsoft.Xrm.Portal.Web.CrmSiteMapProvider to be the default sitemap provider. CrmSiteMapProvider use Site Marker entity (adx_sitemarker) contained in portalbase solution as persistent store.This can be set up in web.config

<?xml version="1.0"?>
<configuration>
	<system.web>
		<siteMap enabled="true" defaultProvider="Crm">
			<providers>
				<clear/>
				<add name="Crm" type="Microsoft.Xrm.Portal.Web.CrmSiteMapProvider, Microsoft.Xrm.Portal" securityTrimmingEnabled="true"/>
			</providers>
		</siteMap>
	<system.web>
<configuration>

Syntax:

<%$ CrmSiteMap: SiteMarker=siteMarker, Return=return, Eval=eval, Format=format, Portal=portal%>
<%$ CrmSiteMap: siteMarker, return, eval, format, portal%>

Snippet Expression takes a format of comma separated name value pairs, any pair is optional and the name of the pair is optional as well. If name is omitted, then the sequence is significant.

The first name value pair (SiteMarker) is the value of Name attribute (adx_name) of Site Marker entity (adx_sitemarker) contained in portalbase solution.

One instance of CrmSiteMapNode will be created for the rest of expression evaluation.

CrmSiteMapNode contains four more extra properties than base ASP.NET SiteMapNode object: Entity, LastModified, RewriteUrl and StatusCode. The entity will be the Web Page (adx_webpage) entity instance related to the Site Marker entity (adx_sitemarker) with the name specified.

The Web Page (adx_webpage) entity will be retrieved from CRM first, and the Partial Url (adx_partialurl) attribute value will be used to find CrmSiteMapNode within sitemap. If special value “Current” is specified, the current web page path will be used to find CrmSiteMapNode within sitemap.

CrmSiteMapProvider use Site Marker entity (adx_sitemarker) contained in portalbase solution as persistent store. SiteMap is defined as a view of Site Marker entity for the specified web site. If the partial url/web page path from the previous description is found in this list of Site Marker entities. A corresponding CrmSiteMapNode will be created otherwise one CrmSiteMapNode instance with “Page Not Found” Site Marker will be created. If “Page Not Found” Site Marker does not exist in CRM, null will be returned.

The second name value pair (Return) can be set to either “Entity” or “Url“, if it is not specified the value of Eval and Format will determine the expression value, if any other value is specified an instance of CrmSiteMapNode will be returned.

If it is set to “Entity”, the value of the expression will be the Web Page (adx_webpage) entity instance related to the Site Marker entity (adx_sitemarker) with the name specified for the first name value pair.

If it is set to “Url”, the value of the expression will be the Partial Url (adx_partialurl) attribute value of the Web Page (adx_webpage) entity instance related to the Site Marker entity (adx_sitemarker) with the name specified for the first name value pair.

If we have the following web page created within CRM (Name=”View Scheduled Services” Partial Url=”view-scheduled-services”)

the following Site Marker created within CRM which related to the previous web page (Name=”View Scheduled Services” Page=”View Scheduled Services”)

The following expression

<asp:Literal ID="Literal1" runat="server" Text="<%$ CrmSiteMap: SiteMarker=View Scheduled Services, Return=Entity%>" />

will produce the following error, this verify that the value of the CrmSiteMap expression is an Entity with logical name “adx_webpage”

The following CrmSiteMap expression will be evaluated to “/view-scheduled-services”

<asp:Literal ID="Literal1" runat="server" Text="<%$ CrmSiteMap: SiteMarker=View Scheduled Services, Return=Url%>" />

The third and fourth name value pair (Eval & Format) will only be taken into consideration when second name value pair (Return) is not specified. The value then will  be passed as parameters to System.Web.UI.DataBinder.Eval(CrmSiteMapNode, eval, format) and the value is substituted for the expression syntax when the second name value pair is not specified.

The following expression will product “Partial Url is: /view-scheduled-services”

<asp:Literal ID="Literal1" runat="server" Text="<%$ CrmSiteMap: SiteMarker=View Scheduled Services, Eval=Url, Format=Partial Url is {0}%>" />
Advertisements

6 comments on “Dynamics CRM 2011 Portal Development – CrmSiteMap Expression

  1. Pingback: Dynamics CRM 2011 Portal Development – Hello World | Zhongchen Zhou's Blog

  2. Pingback: Dynamics CRM 2011 Portal Development – Snippet Expression | Zhongchen Zhou's Blog

  3. Pingback: Dynamics CRM 2011 Portal Development – PortalContext Expression | Zhongchen Zhou's Blog

  4. Pingback: Dynamics CRM 2011 Portal Development – TimeZone Expression | Zhongchen Zhou's Blog

  5. Pingback: Dynamics CRM 2011 Portal Development | Zhongchen Zhou's Blog

  6. Pingback: Dynamics CRM 2011 Portal Development – CrmEntityDataSource | Zhongchen Zhou's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s