Answered by:
Xrm.Page.context.getClientUrl() returning wrong organization

Question
-
on development environment i have different organizations for SIT , UAT and DEV ;
sometimes the JS Xrm.Page.context.getClientUrl() return wrong url; any ideas or suggestions..
I love Codingggggggggggg
Wednesday, January 22, 2014 11:02 PM
Answers
-
Hi All I found the error;
when you are referring to the clientGlobalcontext.js.aspx page you should not give the relative path of the webresources folder
so basically you should modify this ref <!-- <script src="../../WebResources/ClientGlobalContext.js.aspx"></script>-->
to this one<scriptsrc="ClientGlobalContext.js.aspx"></script>
here it is on MSDN http://msdn.microsoft.com/en-us/library/gg328541.aspx
read the note section
NOTE
Using a relative path including the root WebResources folder, for example,
/WebResources/ClientGlobalContext.js.aspx
, is not recommended because it can cause the page to lose organization context in a multi-tenant environment.I love Codingggggggggggg
- Marked as answer by RaghuveerLovesCoding Thursday, January 23, 2014 6:26 PM
Thursday, January 23, 2014 6:26 PM
All replies
-
what do you mean by return wrong url? is it the "http://{address}/{org}"?Thursday, January 23, 2014 3:44 AM
-
yes;
I have org1, org2, org3 on the same server and my js is inside the html page of webresources
due to unknown reasons when the call is made from org2 it brings the url as http://server1/org1;
some other developers in our team encountered the same thing.
I love Codingggggggggggg
Thursday, January 23, 2014 3:54 PM -
you can use like this.
var serverUrl = location.protocol + "//" + location.host + "/" + Xrm.Page.context.getOrgUniqueName();
Thursday, January 23, 2014 4:08 PM -
my whole context page is coming from wrong org; so it cannot get the right orguniqename
I love Codingggggggggggg
Thursday, January 23, 2014 4:34 PM -
Hi All I found the error;
when you are referring to the clientGlobalcontext.js.aspx page you should not give the relative path of the webresources folder
so basically you should modify this ref <!-- <script src="../../WebResources/ClientGlobalContext.js.aspx"></script>-->
to this one<scriptsrc="ClientGlobalContext.js.aspx"></script>
here it is on MSDN http://msdn.microsoft.com/en-us/library/gg328541.aspx
read the note section
NOTE
Using a relative path including the root WebResources folder, for example,
/WebResources/ClientGlobalContext.js.aspx
, is not recommended because it can cause the page to lose organization context in a multi-tenant environment.I love Codingggggggggggg
- Marked as answer by RaghuveerLovesCoding Thursday, January 23, 2014 6:26 PM
Thursday, January 23, 2014 6:26 PM