-
Notifications
You must be signed in to change notification settings - Fork 519
MetadataCatalogRecipes
Demonstrates how to query the Metadata Catalog. This is sometimes faster that Schema Describe calls especially for large complex orgs
Group Data Recipes
SUPPRESSWARNINGS
Demonstrates how to query the EntityDefinition Object to find all formula fields in your Org. This method returns a Map of Object's Qualified API name -> Map of Field Names -> Types
Note: This method has a false-positive PMD warning. PMD isn't aware of the purpose or functionality of CanTheUser.* so it doesn't undersatnd that we are, in fact, checking for CRUD / FLS permissions prior to querying.
public static Map<String,Map<String,String>> findAllFormulaFields()Map<String,Map<String,String>>
Map<String, Map<String, String>> results =
MetadataCatalogRecipes.findAllFormulaFields();
System.debug(results);SUPPRESSWARNINGS
Demonstrates how to query the metadata catalog to find all fields on the Contact object that establish a relationship to the Account Object.
Note: This method has a false-positive PMD warning. PMD isn't aware of the purpose or functionality of CanTheUser.* so it doesn't undersatnd that we are, in fact, checking for CRUD / FLS permissions prior to querying.
public static List<MetadataCatalogRecipes.LookupRelationshipDefinition> findAllContactFieldsThatLookupToAccount()List<MetadataCatalogRecipes.LookupRelationshipDefinition>
List<MetadataCatalogRecipes.LookupRelationshipDefinition> results =
MetadataCatalogRecipes.findAllContactFieldsThatLookupToAccount();
System.debug(results);internal data object for information about a Lookup Relationship
Specifies what object this one looks up to
public looksUpToString
Specifies the name of the Object
public developerNameString
Specifies the Relationship field name
public relationshipNameString
Specifies the Data Type Of this Object
public dataTypeString
Constructor that transforms a Field Definition object into a LookupRelationshipDefinition Object.
public LookupRelationshipDefinition(FieldDefinition fd)| Name | Type | Description |
|---|---|---|
| fd | FieldDefinition | a FieldDefinition Object |
FieldDefinition fd = [SELECT Id, DeveloperName, RelationshipNme,
DataType
FROM FieldDefinition LIMIT 1];
MetadataCatalogRecipes.LookupRelationshipDefinition lrd = new
MetadataCatalogRecipes.LookupRelationshipDefinition(fd);
System.debug(lrd);