Answered by:
Customize SiteMapXml for CRM 4.0

Question
-
Hi all,
I want to know how to programmatically customize SiteMapXml for CRM 4.0. I need to add a new subarea but having problems with it?
Any code samples will be highy appreciated.I tried something like this-
//crm service and authentication code segment already here here
ExportXmlRequest export = new ExportXmlRequest();
export.ParameterXml = "<export><entities></entities><nodes><node>sitemap</node></nodes></export>"; //dont know this works for crm 4.0
ExportXmlResponse entities = (ExportXmlResponse)service.Execute(export);
XmlDocument siteMapXml = new XmlDocument();
siteMapXml.PreserveWhitespace = true;
siteMapXml.LoadXml(entities.ExportXml);
SiteMapCustomizer siteMapEditor = new SiteMapCustomizer(siteMapXml);
SubArea subArea = new SubArea();
subArea.Id = "nav_testapp";
subArea.PassParams = PassParamsType.True;
subArea.Icon = "/testpath/Test/test.png";
subArea.Url = "/../isv/test/test.aspx";
LocalizedLabel lbl = new LocalizedLabel();
lbl.Lcid = 1033;
lbl.Text = "Test App";
subArea.AddTitle("Test App", 1033);
ImportXmlRequest import = new ImportXmlRequest();
import.ParameterXml = "<import><entities></entities><nodes><node>sitemap</node></nodes></import>";
import.CustomizationXml = siteMapXml.OuterXml;
service.Execute(import);Tuesday, June 1, 2010 1:16 AM
Answers
-
(sorry abt marking as answer )
As regards the sitemap customizing - I was on a wild goose chase until I came across the recently released Xrm sdk. Sitemap customization is a breeze with this new set of SDK.
One can reference the sitemap (crm.organization.sitemapxml - where crm is an instance of XrmDataContext) and make changes to the sitemap xml. once done, you can attach the sitemap to that organization and update the crm object; and there you have it - you can see the changes after logging into the CRM instance.
Code snippet:
crm = new Xrm.XrmDataContext ("Crm");
var yourOrg = crm.organizations.where (o => o.name.Contains ("your org name")).Single();
XmlDocument xDoc = new XDocument ();
xDoc.Load (yourOrg.sitemapxml);
// Construct a new site map tag and attach to the XmlDocument (xDoc)
// Assign the new sitemap to the org
yourOrg.sitemapxml = xDoc.OuterXml;
crm.UpdateObject (yourOrg);
crm.SaveChanges ();
Well, that's it - trust this will help.
- Marked as answer by DavidJennawayMVP, Moderator Wednesday, July 28, 2010 10:55 AM
Friday, July 2, 2010 8:31 AM
All replies
-
check my blog for the CRM demonstartion toolkit
Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1- Proposed as answer by Tiaan van Niekerk Tuesday, June 1, 2010 3:54 AM
- Marked as answer by Jim Glass Jr Tuesday, June 1, 2010 4:46 PM
- Unmarked as answer by birendra gaihre Tuesday, June 1, 2010 5:00 PM
Tuesday, June 1, 2010 3:54 AM -
Thanks Tiaan,
The tool is awesome but still I want to know how to program it.Let me know if anyone has idea(s) on this.
- Proposed as answer by K Rajesh Menon Friday, July 2, 2010 8:19 AM
Tuesday, June 1, 2010 4:54 PM -
(sorry abt marking as answer )
As regards the sitemap customizing - I was on a wild goose chase until I came across the recently released Xrm sdk. Sitemap customization is a breeze with this new set of SDK.
One can reference the sitemap (crm.organization.sitemapxml - where crm is an instance of XrmDataContext) and make changes to the sitemap xml. once done, you can attach the sitemap to that organization and update the crm object; and there you have it - you can see the changes after logging into the CRM instance.
Code snippet:
crm = new Xrm.XrmDataContext ("Crm");
var yourOrg = crm.organizations.where (o => o.name.Contains ("your org name")).Single();
XmlDocument xDoc = new XDocument ();
xDoc.Load (yourOrg.sitemapxml);
// Construct a new site map tag and attach to the XmlDocument (xDoc)
// Assign the new sitemap to the org
yourOrg.sitemapxml = xDoc.OuterXml;
crm.UpdateObject (yourOrg);
crm.SaveChanges ();
Well, that's it - trust this will help.
- Marked as answer by DavidJennawayMVP, Moderator Wednesday, July 28, 2010 10:55 AM
Friday, July 2, 2010 8:31 AM