Play Games

Search This Blog

Wednesday, January 6, 2016

Get field Type with dynamic apex

Get field Type with dynamic apex

Example:We want to know the type of "AccountSource" field of Account object.
Piece Of Code:
Map<String, Schema.SObjectField> accountFieldMap;
accountFieldMap = Schema.SObjectType.Account.fields.getMap();
Schema.SObjectField field = accountFieldMap.get('AccountSource');
Schema.DisplayType fieldType= field.getDescribe().getType();
system.debug('Type of AccountSource Field :'+fieldType);
Output:

No comments:

Post a Comment