sObject Field Tips & Tricks

Apex Nov 5, 2014

What all can we do with sObject Field API Name, here we go

To Get HelpText

String Field_Name = Object_Name__c.Field_Name__c.getDescribe().getInlineHelpText();

To Get Label

String Field_Name = Object_Name__c.Field_Name__c.getDescribe().getLabel();

To Get Default Value

String Field_Name = Object_Name__c.Field_Name__c.getDescribe().getDefaultValue();

To Get Digits

String Field_Name = Object_Name__c.Field_Name__c.getDescribe().getDigits();

To Get Length

Integer string_length = Object_Name__c.Field_Name__c.getDescribe().getLength();

To Get PickList Values

List<Schema.PicklistEntry> pickList_values = Object_Name__c.Field_Name__c.getDescribe().getPicklistValues();

To Get Precision

Integer precision = Object_Name__c.Field_Name__c.getDescribe().getPrecision();

To Get Relationship Name

String Field_Name = Object_Name__c.Field_Name__c.getDescribe().getRelationshipName();

To Get Relationship Order

Integer isChild = Object_Name__c.Field_Name__c.getDescribe().getRelationshipOrder();

// Returns 1 if the field is a child, 0 otherwise.

To Know isAccessible

String Field_Name = Object_Name__c.Field_Name__c.getDescribe().isAccessible();

And for more methods click here

Phanindra Mangipudi

Salesforce, Lightning Web Componets, Node.Js, Angular 2+, Bootstrap