- This is a project based on work by Evan Callahan (formerly of Groundwire, and now at Salesforce) who wrote
- this class (repo has been deleted - Sadface) a
- long time ago to reduce the number of describe calls required to work with Record Types.
+ This is a project based on work by
+ Evan Callahan
+ (formerly of Groundwire, and now at Salesforce) who wrote
+ this class
+ (repo has been deleted - Sadface) a long time ago to reduce the number of describe calls required to work with Record Types.
- I've updated the project (by pulling test code out of the main class - that's how old it was!) and have added some additional methods. The included
- test class has 100% coverage, so pull this into your org and get cracking!
+ I've updated the project (by pulling test code out of the main class - that's how old it was!) and have added some additional methods. The
+ included test class has 100% coverage, so pull this into your org and get cracking!
Of note: The test code assumes that you have no record types for the Solution object. If you do, you may need to remove that test method.
The class and test class are found in this folder. Feel free to copy/paste directly into your org.
+
+ The class and test class are found in this
+ folder
+ . Feel free to copy/paste directly into your org.
+
Features
- Given combinations of an sObject name, Record Type name, Record Type developer name, and Record Type Id, this class will let you return the other possible
- parameters. Give it an sObject name and a Record Type developer name, and get the Record Type Id.
+ Given combinations of an sObject name, Record Type name, Record Type developer name, and Record Type Id, this class will let you return the other
+ possible parameters. Give it an sObject name and a Record Type developer name, and get the Record Type Id.
The main purpose is to minimize describe calls, which will speed up your code.
Add methods to get default RecordTypeId, handling situation where no RT is on the Profile but at least one is avaialble via Permission Set.
-
Add test methods against Account and Solution objects, as we assume Solution has no defined record types. (Change for your org if you have them.)
+
+ Add methods to get default RecordTypeId, handling situation where no RT is on the Profile but at least one is avaialble via Permission Set.
+
+
+ Add test methods against Account and Solution objects, as we assume Solution has no defined record types. (Change for your org if you have
+ them.)
+
Include table of all methods on documentation site
2022-03
-
BREAKING CHANGE: Replaced "DeveloperName" with "DevName" in all method names. Update your code to refer to the new methods.
+
+ BREAKING CHANGE: Replaced "DeveloperName" with "DevName" in all method names. Update your code to refer to the new
+ methods.
+
2022-03
- Add maps Id => Name and Id => DeveloperName for ease of use when wanting to refer to a record type by Id without including the object, since Id is
- globally unique
+ Add maps Id => Name and Id => DeveloperName for ease of use when wanting to refer to a record type by Id without including the object,
+ since Id is globally unique
This class is meant to allow for access to Record Type information from within other classes.
- It is called statically, and therefore will supply the same information to all calls made from within one transaction, or set of trigger calls. This is
- beneficial because this info should be the same for all calls in a transaction, and by calling it statically we reduce the calls that are made, making the
- total transaction more efficient.
+ It is called statically, and therefore will supply the same information to all calls made from within one transaction, or set of trigger calls.
+ This is beneficial because this info should be the same for all calls in a transaction, and by calling it statically we reduce the calls that are
+ made, making the total transaction more efficient.
- Usage recommendation: Always use DeveloperName instead of Name, as this is more likely to be hard-coded in places, while the Name is actually a label and
- may change (especially due to user language).
+ Usage recommendation: Always use DeveloperName instead of Name, as this is more likely to be hard-coded in places, while the Name is actually a
+ label and may change (especially due to user language).
These are the most common methods to be used. They are the fastest ways to get a Record Type Id from an object name and the developer name, for example.
- There are some overloaded methods included for historical purposes (the ones that accept a Record Type Id and an object name and return the developer name).
- While the object name is, technically, optional, that method is faster because it does not require memoizing a SOQL query.
+ These are the most common methods to be used. They are the fastest ways to get a Record Type Id from an object name and the developer name, for
+ example.
+
+
+ There are some overloaded methods included for historical purposes (the ones that accept a Record Type Id and an object name and return the
+ developer name). While the object name is, technically, optional, that method is faster because it does not require memoizing a SOQL query.
@@ -227,8 +259,8 @@
Helper Methods
Less Common Methods
- The most useful of these may be the SelectList generators for Visualforce. However, if you are using LWC, you may prefer to use some of the other methods and
- to parse the returned list of RecordTypeInfo items yourself.
+ The most useful of these may be the SelectList generators for Visualforce. However, if you are using LWC, you may prefer to use some of the other
+ methods and to parse the returned list of RecordTypeInfo items yourself.
- These are the most common methods to be used. They are the fastest ways to get a Record Type Id from an object name and the developer name, for example.
+ These are the most common methods to be used. They are the fastest ways to get a Record Type Id from an object name and the developer name, for
+ example.
- There are some overloaded methods included for historical purposes (the ones that accept a Record Type Id and an object name and return the developer name).
- While the object name is, technically, optional, that method is faster because it does not require memoizing a SOQL query.
+ There are some overloaded methods included for historical purposes (the ones that accept a Record Type Id and an object name and return the
+ developer name). While the object name is, technically, optional, that method is faster because it does not require memoizing a SOQL query.