function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

get Object data type in apex class

Hi All,



Please help me...


For one of my apex class i need to fill out some mandatory fields with dummy data. Actually i want to get the field data type in apex class to fill dummy data. How i can do this.

Best Answer chosen by Admin (Salesforce Developers) 

You can get a field's data type with something like this (I've used an Account field in this example)


Schema.DisplayType dt = Schema.sObjectType.Account.fields.AnnualRevenue.getType();
System.debug('***** Type ' + +' *****');


The result here is Currency. Your question was kind of vague so it's possible I missed it's intent. if so feel free to clarify.