public
Created

Apex Get Current URL Method

  • Download Gist
getCurrentURL.cls
Apex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/**
* @description Various Apex methods for working with URLs
*
* @author Mac Anderson
*
* @version 1.0
*
* @moreinfo http://macscloud.com
*/
 
public class UrlMethods {
 
String BaseUrl; // The Url w/o the page (ex: 'https://na9.salesforce.com/')
String PageUrl; // The Url of the page (ex: '/apex/SomePageName')
String FullUrl; // The full Url of the current page w/query string parameters
// (ex: 'https://na9.salesforce.com/apex/SomePageName?x=1&y=2&z=3')
String Environment; // Writing code that can detect if it is executing in production or a sandbox
// can be extremely useful especially if working with sensitive data.
public UrlMethods() { // Constructor
BaseUrl = URL.getSalesforceBaseUrl().toExternalForm(); // (Example: 'https://na9.salesforce.com/')
}
 
}

/**

  • @description Various Apex methods for working with URLs *
  • @author Mac Anderson *
  • @version 1.0 *
  • @moreinfo http://macscloud.com
    */

public class UrlMethods {

String BaseUrl;         // The Url w/o the page (ex: 'https://na9.salesforce.com/')

String PageUrl;         // The Url of the page (ex: '/apex/SomePageName')

String FullUrl;         // The full Url of the current page w/query string parameters 
                        // (ex: 'https://na9.salesforce.com/apex/SomePageName?x=1&y=2&z=3')

String Environment;     // Writing code that can detect if it is executing in production or a sandbox
                        // can be extremely useful especially if working with sensitive data.

public UrlMethods() {   // Constructor

    BaseUrl = URL.getSalesforceBaseUrl().toExternalForm(); // (Example: 'https://na9.salesforce.com/')

}

}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.