Hiding navigation pane in mscrm2011:
Javascript approach:
//Ensure navitem is "quoted" to represent string
// bool: true = Visible, false = removed
var objNavItem = Xrm.Page.ui.navigation.items.get(navitem);
objNavItem.setVisible(bool);
C# code approach:
/// Retrieve the sitemap
QueryExpression query = new QueryExpression();
query.EntityName = "sitemap";
query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet(true);
EntityCollection col = _service.RetrieveMultiple(query);
Entity sitemap = null;
if (col != null && col.Entities.Count > 0)
sitemap = col.Entities[0];
///Parse the sitemap entity to an XDocument object
string sitemapcontent = sitemap["sitemapxml"].ToString();
XDocument sitemapxml = XDocument.Parse(sitemapcontent);
You can now change the sitemap by modifying the sitemapxml object. After you made your changes, it's time to save these changes.
//// Update the sitemap
sitemap["sitemapxml"] = sitemapxml.ToString();
_service.Update(sitemap);
//// Publish the sitemap
PublishXmlRequest request = new PublishXmlRequest();
request.ParameterXml = "<importexportxml><sitemaps><sitemap></sitemap></sitemaps></importexportxml>";
_service.Execute(request);
No comments:
Post a Comment