+ Start a Discussion
Balakrishna RaoBalakrishna Rao 

Is there a way in apex to determine whether the field is standard field or custom field in dynamic apex

i have few things to ask
1) is there way in apex to generate all custom field in apex for a particular object.
2) In dynamic apex is there a way to check the field is standard field or custom field
AbhinavAbhinav (Salesforce Developers) 
Hi Balakrishna,

I think this will work:
String apiName='Account';
    SObjectType objType = ((SObject) (Type.forName('Schema.' + apiName).newInstance())).getSObjectType();
    Map<String, SObjectField> fieldsByName = objType.getDescribe().fields.getMap();
    List<String> customFields = new List<String>();

    for (SObjectField field : fieldsByName.values()) {
        if (field.getDescribe().isCustom()) {

    System.debug('customFields => ' + customFields);



If it helps mark it as best answer.

Jay MandalJay Mandal
1. To generate all fields in apex
To fields of Account object
Map<String,Schema.SObjectField > fieldmap=Schema.SObjectType.Account.fields.getmap();

OR  dynamically you can generate  field for any object
Map<String,Schema.SObjectField > fieldmap= ((SObject) Type.forName(sobjName)
2.Check if fields is custom or standard
Schema.DescribeFieldResult dfr = Account.Description.getDescribe();
Boolean iscustomField=dfr.isCustom();
Or you can use

Schema.SObjectField field= ((SObject) Type.forName(
Boolean iscustomField=field.getDescribe().isCustom();
Please Mark this as best answer.