How to get the Salesforce Instance Server URL from APEX Class?

This can be used to get the ID of current record.


ApexPages.CurrentPage().getParameters().get('id');

This can be used to get the current host in the url for e.g: “cs8.salesforce.com”.


ApexPages.CurrentPage().getHeaders().get('host');

Written by 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*