//Create a new account called "Test Account" that we will create a link for later. Account acc = new Account(Name = 'Test Account'); Insert acc; //Get the base URL. String baseURL = URL.getSalesforceBaseUrl().toExternalForm(); System.debug('Base URL: ' + baseURL); //Get the URL for the current request. String currentReqURL = URL.getCurrentRequestUrl().toExternalForm(); System.debug('Current request URL: ' + currentReqURL); //Create the account URL from the base URL. String accURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + acc.Id; System.debug('URL of a particular account: ' + accURL); //Get some parts of the base URL. System.debug('Host: ' + URL.getSalesforceBaseUrl().getHost()); System.debug('Protocol: ' + URL.getSalesforceBaseUrl().getProtocol()); //Get the query string of the current request. System.debug('Query: ' + URL.getCurrentRequestUrl().getQuery());
URL Class in Salesforce
Biswajeet
February 23, 2017 No Comments on URL Class in Salesforce