Dynamic Apex : Creating Dynamic Objects in Apex using GlobalDescribe

by - 2:38 PM

Likewise other programming language often we come across the situation to create a dynamic object. Here is the pretty simple way you can create dynamic objects in salesforce 

Static Objects  -  Lead l = new Lead();

How to create dynamic objects in Salesforce ?
       Here the binding is done in runtime rather than compile time

How to get fields of sObjects ?
         More interestingly we can get easily the map of all the fields here

How to get mendatory fields of sObjects ?
        This is an interesting problem now if you want to get only the mandatory fields, mean this field should own three properties
1. Should not be 'Nullable'
2. Should be Createable
3. Should not have a default value

You May Also Like