Tweak CRM Sitemap to have different URL navigations for different environments

Tags: , , , ,



We want to have different Sitemap subarea Url, so that the Sitemap can be independent of environments & worryfree when we refresh the environments from higher region to lower. Even deployments can be error free & can avoid manual step in post deployment activity.

Dev:

<SubArea Id="nav_hub" ResourceId="Hub_SubArea_Title" DescriptionResourceId="Hub_SubArea_Description" 
   ToolTipResourseId="Hub_SubArea_ToolTip" Icon="/_imgs/Hub_32.png" 
     Url="http://mydevhub.com/home.aspx" AvailableOffline="false" />

UAT:

<SubArea Id="nav_hub" ResourceId="Hub_SubArea_Title" DescriptionResourceId="Hub_SubArea_Description" 
    ToolTipResourseId="Hub_SubArea_ToolTip" Icon="/_imgs/Hub_32.png" 
       Url="http://myuathub.com/home.aspx" AvailableOffline="false" />

Any idea to do that?

Answer

I ended up doing this workaround as we cannot pass dynamic variable url to Sitemap.

1.Created a Sub-Area with url to custom HTML web resource as below:

$webresource:pub/Scripts/External/navigation.html

2.Just used the below content to open a new window based on org url:

<html><head>
<script src="../../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script language="javascript">
var crmUrl = parent.Xrm.Page.context.getClientUrl();

if (crmUrl.indexOf('devinstance.crm.dynamics.com') > 0)
            parent.window.open('http://mydevhub.com/home.aspx');

if (crmUrl.indexOf('uatinstance.crm.dynamics.com') > 0)
            parent.window.open('http://myuathub.com/home.aspx');

</script>
</head><body>
</body></html>


Source: stackoverflow