none
Customize SiteMapXml for CRM 4.0

    Domanda

  • 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);

    martedì 1 giugno 2010 01:16

Risposte

  • (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.

     

    venerdì 2 luglio 2010 08:31

Tutte le risposte

  • check my blog for the CRM demonstartion toolkit
    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    • Proposto come risposta Tiaan van Niekerk martedì 1 giugno 2010 03:54
    • Contrassegnato come risposta Jim Glass Jr martedì 1 giugno 2010 16:46
    • Contrassegno come risposta annullato birendra gaihre martedì 1 giugno 2010 17:00
    martedì 1 giugno 2010 03:54
  • 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.

     

    martedì 1 giugno 2010 16:54
  • (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.

     

    venerdì 2 luglio 2010 08:31