locked
CRM 2011: How to get hostname in Jscript without OrgName RRS feed

  • Question

  • Hi @ all,

    how can I get the current hostname?

    If I use this code:

    var context = Xrm.Page.context;
    var crmServerUrl = context.getServerUrl();

    I get also the OrgName, but I only want to get hostname. Is this possible?

    Regards, Karan

    Wednesday, December 4, 2013 3:58 PM

Answers

  • Hello Karan,

    Try to use following code:

    var result = window.location.protocol + "//" + window.location.host + (window.location.port == "" ? "" : (":" + window.location.port));
    


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    • Proposed as answer by Guido PreiteMVP Thursday, December 5, 2013 8:03 AM
    • Marked as answer by Karan5959 Tuesday, August 19, 2014 2:43 PM
    Wednesday, December 4, 2013 6:56 PM
    Moderator
  • Hi,

    I forgot to mention that I only need hostname without port.

    I solved the problem with: var result = window.location.protocol + "//" + window.location.hostname

    Thanks to all!

    Karan

    • Marked as answer by Karan5959 Thursday, December 5, 2013 7:50 AM
    Thursday, December 5, 2013 7:49 AM

All replies