Activity Forums Salesforce® Discussions What is the use of gethost() method in Salesforce apex?

  • Ajit

    Member
    August 11, 2016 at 6:55 am

    Hi Tannu,
    The URL instance method getHost() is used to get the hostname of the Salesforce server that you are using. For instance, if your Salesforce instance is ap1 then you would get the result as "ap1.salesforce.com".

    In case of custom domains, suppose your org has a custom domain "my-dev-org" the method would return "my-dev-org.ap1.my.salesforce.com"

    You can try out the function in anonymous execution block:

    system.debug(URL.getSalesforceBaseUrl().getHost());

  • Shweta

    Member
    January 22, 2020 at 2:44 pm

    getHost() method is used for get the host name of current running URL.

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos