0

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?

2 Answers2

2

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>
  • We can store the required destination url as a key value pair in a custom configuration entity and each environment can have its unique value. This has to be maintained in each environment and can be queried in above web resource instead of hard coding. – Arun Vinoth-Precog Tech - MVP Sep 13 '20 at 14:43
0

In case anyone else lands here (and since I can't comment yet) the answer provided is deprecated.

The newer way of achieving this is

var globalContext = Xrm.Utility.getGlobalContext();
globalContext.getClientUrl();

(Source)

A_R_
  • 21
  • 3