Dynamic Apex – Sky is The Limit – Explained with Example

Today I am going to explain Dynamic Apex with examples. Dynamic Apex will help developer to create more flexible and robust application because with the help of Dynamic Apex, developer can access the sObject and field describe information, access Salesforce application information. Another great help is that with Dynamic Apex, developer can now write dynamic SOQL, SOSL and DML statements. So basically with dynamic apex, you have the magic wand in your hand.So without any further delay, let’s start the power of magic wand.Basics of Apex Describe:In order to get information about sObjects in Salesforce, you have two options – either use tokens or use describeSObjects Schema methods.Apex provides two data structures and a method for fetching information about sObjects and fields. They are listed below -Token – This is a lightweight, serializable reference to an sObject or a field that is validated at run time. Since they are lightweight, using them make your code faster and more efficient.The describeSObjects method – This method from the Schema class will perform the describe on sObject Types.Describe result – This is basically the object of  type Schema.DescribeSObjectResult which holds the result i.e. contains all the describe properties for the sObject or field. These objects are not serializable and validated always at runtime. Let’s get into more details before we jump into the examples -Schema Describe -Schema Describe is a way to programmatically...

Read More