You need to sign in to do that
Don't have an account?
Balakrishna 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
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
I think this will work:
reference:
https://salesforce.stackexchange.com/questions/270732/how-to-get-list-of-custom-fields-using-dynamic-apex
If it helps mark it as best answer.
Thanks!
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)
.newInstance())
.getSObjectType()
.getDescribe()
.fields.getMap();
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(
objName
)
.newInstance())
.getSObjectType()
.getDescribe()
.fields.getMap()
.get(FieldName);
Boolean iscustomField=field.getDescribe().isCustom();
Please Mark this as best answer.