Skip to main content

Posts

Featured

Describe sObject using Apex

Describing the object This code snippet example will populate Account object information as a JSON string. //1.Generate token Account acc = new Account (); Schema . SObjectType obj = acc . getSObjectType (); System . debug ( obj ); //2.Obtain the describe information Schema . DescribeSObjectResult objResults = obj . getDescribe (); System . debug ( JSON . serialize ( objResults )); JSON output Describing a field in a sObject Below code snippet will describe the Account's Name field Schema . sObjectField field = Account . Name ; Schema . DescribeFieldResult fieldResult = field . getDescribe (); System . debug ( fieldResult ); Output Schema.DescribeFieldResult [ getByteLength= 765 ;getCalculatedFormula= null ;getCompoundFieldName=Name;getController= null ;getDefaultValue= null ;getDefaultValueFormula= null ;getDigits= 0 ;getFilteredLookupInfo= null ;getInlineHelpText= null ;getLabel=Account Name;getLength= 255 ;getLocalName=

Latest Posts

Reserved Keywords in APEX