Wednesday 6 October 2021

Get the Api name from soql

 



List<FieldDefinition> lstApiRecords =[SELECT Label, DeveloperName, Description, DataType, ExtraTypeInfo,  Length, Precision, Scale,QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName ='Account'  order by label ASC];

        if(lstApiRecords.size()>0){

            for(FieldDefinition record:lstApiRecords){

                if(string.isNotEmpty(record.label)){  

                    system.debug('Field Infoemartin========================>');

                    system.debug('Label  ==='+record.Label);

                    system.debug('DeveloperName  ==='+record.DeveloperName);

                    system.debug('Description  ==='+record.Description);

                    system.debug('DataType  ==='+record.DataType);

                    system.debug('ExtraTypeInfo  ==='+record.ExtraTypeInfo);

                    system.debug('Length  ==='+record.Length);

                    system.debug('Precision  ==='+record.Precision);

                    system.debug('Scale  ==='+record.Scale);

                    system.debug('QualifiedApiName  ==='+record.QualifiedApiName);

                }                               

            }

        }   


Result :