Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Apex Get Current URL Method
/**
* @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/')
}
}
@macanderson
Owner

/**

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/')

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.