locked
getServerUrl() RRS feed

  • Question

  • Our installation was originally created in "ATest" we copied this to "Alive" and now I am trying to get a webresource working on "AQA".

    If I use 

                    var serverUrl = Xrm.Page.context.getServerUrl();
                    var serverUrl2 = document.location.protocol + '//' + document.location.host + '/' + Xrm.Page.context.getOrgUniqueName();

    this returns "ATest" as the serverUrl

    I have also tried 

    var getServerUrl3 = Xrm.Page.context.getClientUrl();

    This errors with Object doesn't support property or method 'getClientUrl'

    As I am new to javascript I am finding things a little difficult to say the least.

    regards,

    Matt

    Thursday, August 28, 2014 10:22 AM

Answers

  • window.parent.Xrm.Page.context.getServerUrl();

    Fixes my issue, I assume the webresource is accessing the original systems base URL where as the Parent forces it to look at the context it is being run in.

    Matt

    • Marked as answer by Matt_Hirst_UK Thursday, August 28, 2014 10:59 AM
    Thursday, August 28, 2014 10:59 AM

All replies

  • Xrm.Page.context.prependOrgName("/XRMServices/2011/OrganizationData.svc")

    the above also reports server as "ATest".

    I have previously used 

    document.location.protocol + '//' + document.location.host + '/' + Xrm.Page.context.getOrgUniqueName();
    when putting code behind forms but this is the first time I have tried to create a webresource.

    Matt

    Thursday, August 28, 2014 10:34 AM
  • window.parent.Xrm.Page.context.getServerUrl();

    Fixes my issue, I assume the webresource is accessing the original systems base URL where as the Parent forces it to look at the context it is being run in.

    Matt

    • Marked as answer by Matt_Hirst_UK Thursday, August 28, 2014 10:59 AM
    Thursday, August 28, 2014 10:59 AM