All about UserInfo Class in Apex

UserInfo class contains methods to get the LoggedIn User or Context User  information. All methods in UserInfo class are static method, so you can access the methods using the syntax – ClassName.methodName() like UserInfo.methodName() getUserId() Method – return the current user Id. Id currentUserId = UserInfo.getUserId(); getProfileId() Method –  returns the current user profile Id.Continue reading “All about UserInfo Class in Apex”

Apex Exception Handling and Built-In methods in Exception

In Apex Exception are handles using try, catch and finally. try – block of code where an error can occur. catch – block handles particular type of exception. A single try block can have zero or more exception block.  Each catch block must have unique exception type. Once a particular exception type is caught isContinue reading “Apex Exception Handling and Built-In methods in Exception”

Database Security Overview provide multilayered approach of data security. Each layer secure data using a different approach. Object Level – security provided by Profiles and Permission-sets. A profile in is a metadata used to group users with common data access requirements. It contains a set of permissions for every object defined in the organization. These permissions determineContinue reading “Database Security Overview”

Static Variable in Apex

A class static variable is a global variable that is associated with a particular class. Multi-threaded application take care of synchronize access of static variables, to avoid race condition. Static variable in Apex have execution context scope and lifetime, which means- static variables can only be accessed from within the execution context in which they areContinue reading “Static Variable in Apex”

SOSL Queries in Salesforce

Salesforce Object Search Language (SOSL) is a Salesforce search language that is used to perform text searches in records. Use SOSL to search fields across multiple standard and custom object records in Salesforce. This is an example of a SOSL query that searches for accounts and contacts that have any fields with the word ‘SFDC’.Continue reading “SOSL Queries in Salesforce”

Validation Rule to Prevent Deletion of Child in Master-Details

You have 2 custom objects, Job Applications and Reviews that have a master-detail relationship. Users should NOT be allowed to delete review records after job application records have been approved. How would a developer meet this requirement? Ans – Use a validation rule in conjunction with a roll-up summary field Validation rule will fire only onContinue reading “Validation Rule to Prevent Deletion of Child in Master-Details”

Previous load of class failed: in Salesforce

line -1, column -1: Previous load of class failed: – In most scenarios, this error message is related to the “IsValid”  checkbox for the code which is being referred to in the message. “IsValid” Checkbox is unchecked for an Apex Class or a Trigger when the metadata on which the code is dependent, has been changedContinue reading “Previous load of class failed: in Salesforce”

Retrieving sObject RecordTypeId in Apex

Usually we required to get the sObject record type id when working in Apex. There are different ways to get the record type Id in Salesforce. We can query from RecordType object to get the record type type id of the object, like below syntax- RecordType rt = [SELECT Id FROM RecordType WHERE SObjectType =Continue reading “Retrieving sObject RecordTypeId in Apex”

Salesforce Object Relationship

Relationships associate objects with other objects. You can define different types of relationships by creating custom relationship fields on an object. The differences between relationship types include how they handle data deletion, record ownership, security, and required fields in page layouts. Master-Detail (1:n) – A parent-child relationship in which the master object controls certain behaviors ofContinue reading “Salesforce Object Relationship”