Newer Version Available
Advanced Policy Migration Example
| Available in: Salesforce Classic and Lightning Experience |
| Available in: Enterprise, Unlimited, and
Developer Editions Requires Salesforce Shield or Salesforce Event Monitoring add-on subscriptions. |
The sample legacy policy in this topic is similar to the legacy Lead Data Export policy but with two key differences. Rather than monitor only leads, this policy monitors several different object types. Also, rather than hard-code an export limit of 2,000 records, this policy defines different limits for different object types.
- Object_Type__c (Picklist)—The object type
- Limit_Value__c (Number(18,0))—The maximum number of records of this object type that a user is allowed to export
The legacy policy queries this custom metadata type to dynamically determine the export limit value for each object type.
In the enhanced policy, we can reuse most of the logic that queries the TransactionSecurityLimit__mdt custom metadata type. The main difference is the code for getting the name of the entities for which we want to query the export limit. In the legacy policy, we use the EntityName key value of the data Map. Its equivalent in the enhanced framework is QueriedEntities. But remember that the QueriedEntities field can contain more than one entity name, because the enhanced framework supports exports on all standard and custom objects. So we take the comma-separated list of queried entities and split it up into a List of entity names.