Posts

Showing posts from April, 2017

Salesforce IDs and URL Tricks and Tips

Image
Salesforce IDs Tricks: Get the current User ID in an Apex. String userId = UserInfo.getUserId();
System.debug('userId: '+userId); Get the Salesforce Org ID in Apex without query.
String OrgId = UserInfo.getOrganizationId();
System.debug('OrgId: '+OrgId); Get the Id from URL in visual force page to apex.
String currentRecordId = ApexPages.currentPage().getparameters().get('ID');  Get the current user Session Id.
String MySessionID = UserInfo.getSessionID();
System.debug('MySessionID: '+MySessionID);  Salesforce URL Tricks:  Get the Namespace prefix of the organization.
String orgNamespace = [SELECT NamespacePrefix FROM Organization].NamespacePrefix;
System.debug('orgNamespace: '+orgNamespace); Get the Installed package namespace prefix.
String pkgNamespace =[select NamespacePrefix from ApexClass where Name =:'Any class from your package'].NamespacePrefix;
System.debug('pkgNamespace: '+pkgNamespace); Get the base URL of Org.
url b…