Some scenarios, we need to validate field is exists or not on the object.
use below simple code it checks the field on an object if the field has existed on the object it returns true otherwise it returns false.
Result:
use below simple code it checks the field on an object if the field has existed on the object it returns true otherwise it returns false.
Example:
Boolean bHasField = Account.getSobjectType().getDescribe().fields.getMap().keySet().contains('phone');
System.debug('bHasField =====> '+bHasField);
No comments:
Post a Comment