SUPPRESSWARNINGS
this class is intended to handle interactions with the Schema class and provide a layer of abstraction for the Schema class, non-mutating string arguments to these methods are understood to be case-insensitive anything named "getName" are understood to return proper API names every argument is understood to be non-null
this method returns the type of a given SObject
public static SObject blankSObjectFrom(Schema.SObjectType sot)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | the sobject type |
SObject
the sobject
TypeException: if the type is not found
this method returns the type of a given SObject
public static SObject blankSObjectFrom(String sObjApiName)
Name | Type | Description |
---|---|---|
sObjApiName | String | the sobject api name |
SObject
the sobject
TypeException: if the type is not found
Return the Schema.DescribeFieldResult
for a given field
public static Schema.DescribeFieldResult describeField(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | Schema.SObjectField the field |
Schema.DescribeFieldResult
,[object Object]
This method is used primarily to discover if a field is polymorphic,
public static Schema.DescribeFieldResult describeField(String sObjApiName, String fieldApiName)
Name | Type | Description |
---|---|---|
sObjApiName | String | : the api name of the sObject |
fieldApiName | String | : the api name of the field |
Schema.DescribeFieldResult
the describe field result
this method returns the child SObject name of a given child relationship
public static String getChildRelationshipChildSObjectName(Schema.ChildRelationship childRelationship)
Name | Type | Description |
---|---|---|
childRelationship | Schema.ChildRelationship | the child relationship |
String
the child relationship name
this method returns the child relationship field name of a given child relationship
public static String getChildRelationshipFieldName(Schema.ChildRelationship childRelationship)
Name | Type | Description |
---|---|---|
childRelationship | Schema.ChildRelationship | the child relationship |
String
the child relationship name
this method returns the child relationship name of a given child relationship
public static String getChildRelationshipName(Schema.ChildRelationship childRelationship)
Name | Type | Description |
---|---|---|
childRelationship | Schema.ChildRelationship | the child relationship |
String
the child relationship name
this method returns the child relationships of a given SObject type
public static List<Schema.ChildRelationship> getChildRelationships(Schema.SObjectType sot)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | the sobject type |
List<Schema.ChildRelationship>
the child relationships
Given an sObject and a field api name, return the field
public static Schema.SObjectField getField(Schema.SObjectType sot, String fieldApiName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | : the sObject type |
fieldApiName | String | : the field api name |
Schema.SObjectField
: the field
Given an sObject and a field api name, return the field
public static Schema.SObjectField getField(SObject sObj, String fieldApiName)
Name | Type | Description |
---|---|---|
sObj | SObject | : the sObject |
fieldApiName | String | : the field api name |
Schema.SObjectField
: the field
Returns the field for a given sObject API name and field API name
public static Schema.SObjectField getField(String sObjApiName, String fieldApiName)
Name | Type | Description |
---|---|---|
sObjApiName | String | String |
fieldApiName | String | String |
Schema.SObjectField
,[object Object]
this method returns the field name of a given field
public static String getFieldName(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | Schema.SObjectField |
String
the field name
this method returns the field name of a given field
public static String getFieldName(Schema.SObjectType sot, String fieldApiName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | the sobject type |
fieldApiName | String | the field api name |
String
the field name
this method returns the field name of a given field
public static String getFieldName(SObject sObj, String fieldApiName)
Name | Type | Description |
---|---|---|
sObj | SObject | the sobject |
fieldApiName | String | the field api name |
String
the field name
: given an sObject and a relationship name, return the field api name
public static String getFieldNameForRelationship(Schema.SObjectType sot, String relationshipName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | : the sObject |
relationshipName | String | : the relationship name |
String
: the field api name
QueryException: : if the relationship name is invalid
Given a list of fields, return their api names
public static List<String> getFieldNames(List<Schema.SObjectField> fields)
Name | Type | Description |
---|---|---|
fields | List<Schema.SObjectField> | : the fields |
List<String>
: the field api names
QueryException: : if the sObject or field names are invalid
this method returns the field relationship name of a given field
public static String getFieldRelationshipName(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | the field |
String
the field relationship name
given an sObject type, return the fields
public static List<Schema.SObjectField> getFields(Schema.SObjectType sot)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | the sObject type |
List<Schema.SObjectField>
the fields
Given a field object, return the SObjectType of the SObject the field is from
public static Schema.SObjectType getFieldSObjectType(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | : the field |
Schema.SObjectType
: the SObjectType of the SObject the field is from
this method returns the field type of a given field
public static Schema.DisplayType getFieldType(Schema.SObjectType sot, String fieldApiName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | the sobject type |
fieldApiName | String | the field api name |
Schema.DisplayType
the field type
this method returns the field type of a given field
public static Schema.DisplayType getFieldType(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | the field |
Schema.DisplayType
the field type
Returns map of polymorphic field lowercase name to API name
public static Map<String,String> getPolymorphicFieldMap()
Map<String,String>
: the map of polymorphic field lowercase name to API name
Returns the "Name" fields, where "Name" is the special SObject for polymorphic relationships
public static List<Schema.SObjectField> getPolymorphicFields()
List<Schema.SObjectField>
the name fields
Returns the "Name" SObjectType
public static Schema.SObjectType getPolymorphicSObjectType()
Schema.SObjectType
the name sobject type
Returns the specified record type's id for a given sObject type
public static Id getRecordTypeId(Schema.SObjectType sot, String recordTypeName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | Schema.SObjectType |
recordTypeName | String | String |
Id
,[object Object]
Given an SObjectField, return the list of objects that the field references
public static List<SObjectType> getReferenceTo(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | : the field |
List<SObjectType>
: the list of objects that the field references
Given an sObject and a relationship name, return the relationship api name
public static String getRelationshipName(Schema.SObjectType sot, String relationshipName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | : the child sObject type |
relationshipName | String | : the relationship name |
String
: the field api name
QueryException: : if the relationship name is invalid
this method returns the API name of a given SObject
public static String getSObjectName(Schema.SObjectType sot)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | the sobject type |
String
the sobject api name
this method returns the API name of a given SObject
public static String getSObjectName(Id recordId)
Name | Type | Description |
---|---|---|
recordId | Id | the record id |
String
the sobject api name
this method returns the API name of a given SObject
public static String getSObjectName(String sObjName)
Name | Type | Description |
---|---|---|
sObjName | String | the sobject name |
String
the sobject api name
TypeException: if the type is not found
this method returns the API name of a given SObject
public static String getSObjectName(SObject sObj)
Name | Type | Description |
---|---|---|
sObj | SObject | the sobject |
String
the sobject api name
this method returns the type of a given SObject
public static Schema.SObjectType getSObjectType(SObject sObj)
Name | Type | Description |
---|---|---|
sObj | SObject | the sobject |
Schema.SObjectType
the sobject type
this method returns the type of a given record id
public static Schema.SObjectType getSObjectType(Id recordId)
Name | Type | Description |
---|---|---|
recordId | Id | the record id |
Schema.SObjectType
the sobject type
this method returns the type of a given SObject
public static Schema.SObjectType getSObjectType(String sObjApiName)
Name | Type | Description |
---|---|---|
sObjApiName | String | the sobject api name |
Schema.SObjectType
the sobject type
TypeException: if the type is not found
Given an SObject type and a field name, return whether the SObject type has the field
public static Boolean hasField(Schema.SObjectType sot, String fieldApiName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | Schema.SObjectType |
fieldApiName | String | String |
Boolean
,[object Object]
Given two fields, return whether they reference the same SObject
public static Boolean idsReferenceSameSObject(Schema.SObjectField field1, Schema.SObjectField field2)
Name | Type | Description |
---|---|---|
field1 | Schema.SObjectField | : the first id or reference field |
field2 | Schema.SObjectField | : the second id or reference field |
Boolean
: whether the fields reference the same SObject
QueryException: : if the sObject or field names are invalid
Given a child relationship and a child relationship name, return whether the child relationship is the same as the child relationship name
public static Boolean isChildRelationship(Schema.ChildRelationship childRelationship, String childRelationshipName)
Name | Type | Description |
---|---|---|
childRelationship | Schema.ChildRelationship | : the child relationship |
childRelationshipName | String | : the child relationship name |
Boolean
: whether the child relationship is the same as the child relationship name
Given an sObject name and a field name, determine if the field is groupable in a query
public static Boolean isFieldGroupable(String sObjectName, String fieldName)
Name | Type | Description |
---|---|---|
sObjectName | String | String |
fieldName | String | String |
Boolean
,[object Object]
given a field type, this method returns whether the field is numeric or not
public static Boolean isFieldNumeric(Schema.DisplayType fieldType)
Name | Type | Description |
---|---|---|
fieldType | Schema.DisplayType | : the field type |
Boolean
: whether the field is numeric or not
Given an sObject and a relationship name, return the field api name
public static Boolean isFieldPolymorphic(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | : the field |
Boolean
: whether the field is polymorphic or not
Given an sObject and a relationship name, return whether the relationship is polymorphic or not
public static Boolean isRelationshipPolymorphic(Schema.SObjectType sot, String relationshipName)
Name | Type | Description |
---|---|---|
sot | Schema.SObjectType | Schema.SObjectType the sObject type |
relationshipName | String | String the relationship name |
Boolean
,[object Object], whether the field is polymorphic or not
Given a field, determine if it is required (system-level)
public static Boolean isRequiredField(Schema.SObjectField field)
Name | Type | Description |
---|---|---|
field | Schema.SObjectField | : the field |
Boolean
: whether the field is required or not