Geeks With Blogs
Oh my god ... not another MS CRM blog Guenter vs. MSCRM

IMPORTANT: You should look at the comment posted by Jeffry van de Vuurst first. In the meantime there was a supported way added to SDK 3.0.4 which describes to change entities, ISV.config, ...

SiteMap XML is a really cool new feature in MS CRM 3.0. The most exciting thing for me is the ability to restrict access to Areas of the SiteMap by specific privileges in MS CRM. In most cases you would modify the SiteMap XML using the supported way by manually exporting, modifying and then importing the XML using the MS CRM UI. But there may be cases when you need to do this programmatically (e.g. using an installer). And there is a way ... but it's not documented in the SDK (at least I didn't find it). So this is totally unsupported and you must use it on your own risk blabla.
There are two web services used for this located in MSCRMServices: ExportXmlWebService and ImportXmlWebService. Just look at the code sample to figure out how to do it:

ExportXmlWebService exportService=new ExportXmlWebService();
exportService.Credentials=System.Net.CredentialCache.DefaultCredentials;  
exportService.Url="
http://localhost/mscrmservices/exportxml.asmx";    

// get the sitemap xml
XmlDocument sitemapDoc=new XmlDocument();
sitemapDoc.LoadXml(
 exportService.Export("<export><entities></entities><nodes><node>sitemap</node></nodes></export>")
);

// add new sub area
XmlElement subArea=sitemapDoc.CreateElement("SubArea");
XmlAttribute attrId=sitemapDoc.CreateAttribute("Id");
attrId.Value="nav_sometest";
XmlAttribute attrTitle=sitemapDoc.CreateAttribute("Title");
attrTitle.Value="Click me for happiness";
XmlAttribute attrIcon=sitemapDoc.CreateAttribute("Icon");
attrIcon.Value="some.gif";
XmlAttribute attrUrl=sitemapDoc.CreateAttribute("Url");
attrUrl.Value="/someurl.aspx";
XmlAttribute attrClient=sitemapDoc.CreateAttribute("Client");
attrClient.Value="Web";

subArea.Attributes.Append(attrId);
subArea.Attributes.Append(attrTitle);
subArea.Attributes.Append(attrIcon);
subArea.Attributes.Append(attrUrl);
subArea.Attributes.Append(attrClient);

sitemapDoc.SelectSingleNode(
 "/ImportExportXml/SiteMap/SiteMap/Area[./@Id = 'Settings']/Group[./@Id = 'Settings']"
).AppendChild(subArea);

ImportXmlWebService importService=new ImportXmlWebService();
importService.Credentials=System.Net.CredentialCache.DefaultCredentials;
importService.Url="
http://localhost/mscrmservices/importxml.asmx"; 


// reimport the sitemap xml
importService.Import("<import><entities></entities><nodes><node>sitemap</node></nodes></import>",
 sitemapDoc.OuterXml);

For isv.config use: <export><entities></entities><nodes><node>isvconfig</node></nodes></export>
For any entity use: <export><entities><entity>account</entity></entities><nodes></nodes></export>

Of course you are able to combine any nodes and entities.

P.S. If you copy and paste this code sample, don't forget to add the two web references and the correct using statements in VS.

Posted on Tuesday, March 14, 2006 7:54 AM | Back to top


Comments on this post: Programmatically change SiteMap XML or any other entity or ISV.config using MS CRM 3.0 web services

# re: Programmatically change SiteMap XML or any other entity or ISV.config using MS CRM 3.0 web services
Requesting Gravatar...
There can't be too many MS CRM blogs out there :)

Anyway, the SDK 3.04 describes a supported way to do programmatic sitemap customizations, using the Microsoft.Crm.Sdk.IsvReadiness classes.

Keep on blogging!
Left by Jeffry van de Vuurst on Mar 29, 2006 1:08 PM

# re: Programmatically change SiteMap XML or any other entity or ISV.config using MS CRM 3.0 web services
Requesting Gravatar...
Hi Jeffry!

You are absolutely right. I didn't know that at the time I was writing this blog post. Microsoft Released this SDK about 10 days later. :-)

In any case using the way described in the SDK is the best way. Thanks for the comment!
Left by Guenter on Mar 30, 2006 4:34 AM

# re: Programmatically change SiteMap XML or any other entity or ISV.config using MS CRM 3.0 web services
Requesting Gravatar...
The Microsoft CRM 2011 solution can be found at http://www.resultondemand.nl/support/blog/post/Change-the-sitemap-content-programmatically-in-CRM-2011-(MSCRM).aspx
Left by Jos Geenen on Apr 05, 2011 1:37 PM

Your comment:
 (will show your gravatar)


Copyright © Guenter Wallnoefer | Powered by: GeeksWithBlogs.net