Skip to content

Commit 1344b75

Browse files
authored
feat: overload get RT from Id (#79)
* feat: overload getRecordTypeFromId to take only Id * chore: adjust methods table * methods table * fix methods table * URL to docs * update readme * ready to try csplit * docs: update ApexDox, including method table * test: add test coverage for overloaded method
1 parent a3cded8 commit 1344b75

File tree

16 files changed

+633
-571
lines changed

16 files changed

+633
-571
lines changed

README.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,70 @@ The class and test class are found in this [folder](/force-app/main/default/clas
2929

3030
## [Changelog](./CHANGELOG.md)
3131

32-
- 2023-08-18
32+
- 2023-09 Overload getRecordTypeFromId so it doesn't require a SobjectType string
33+
34+
- 2023-08
3335

3436
- Add methods to get default RecordTypeId, handling situation where no RT is on the Profile but at least one is avaialble via Permission Set.
3537
- 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.)
38+
- Include table of all methods on documentation site
39+
40+
- 2022-03 BREAKING CHANGE: Replaced "DeveloperName" with "DevName" in all method names. Update your code to refer to the new methods.
41+
42+
- 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
43+
44+
- 2022-01 Initial Release
45+
46+
## Code Header
47+
48+
Written by Evan Callahan, copyright (c) 2010 Groundwire
49+
50+
- This program is released under the [GNU General Public License](./LICENSE). http://www.gnu.org/licenses/
51+
- This class is meant to allow for access to Record Type information from within other classes.
52+
- 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.
53+
54+
Updated by David Schach, copyright (c) 2021 X-Squared on Demand
55+
56+
- 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).
57+
58+
# Library Methods
59+
60+
(Full documentation at [https://dschach.github.io/record-types](https://dschach.github.io/record-types/))
61+
62+
## Most Common Methods
63+
64+
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.
65+
66+
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).
67+
While the object name is, technically, optional, that method is faster because it does not require memoizing a SOQL query.
68+
69+
| Parameters / Output | Id | Name | DeveloperName |
70+
| ----------------------------- | -------------------------- | ---------------------------- | ---------------------------- |
71+
| objectName, recordTypeName | getRecordTypeIdFromName | | |
72+
| objectName, recordTypeName | | | getRecordTypeDevNameFromName |
73+
| objectName, recordTypeDevName | | | getRecordTypeFromDevName |
74+
| objectName, recordTypeDevName | | getRecordTypeNameFromDevName | |
75+
| objectName, recordTypeDevName | getRecordTypeIdFromDevName | | |
76+
| objectName, recordTypeId | | getRecordTypeNameFromId | |
77+
| objectName, recordTypeId | | | getRecordTypeDevNameFromId |
78+
| recordTypeId | | getRecordTypeNameFromId | |
79+
| recordTypeId | | | getRecordTypeDevNameFromId |
80+
81+
## Less Common Methods
3682

37-
- 2022-03-29 BREAKING CHANGE: Replaced "DeveloperName" with "DevName" in all method names. Update your code to refer to the new methods.
83+
These methods are used less often but may be useful.
3884

39-
- 2022-03-29 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
85+
The most useful of these are 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.
4086

41-
- 2022-01-19 Initial Release
87+
| Parameters / Output | Schema.RecordTypeInfo | Map(String, Id) | SelectList | Set<Id> |
88+
| ---------------------------------------- | --------------------- | ---------------------------------- | --------------------------------- | ------------------------------ |
89+
| recordTypeId | getRecordTypeFromId | | | |
90+
| objectName, recordTypeId | getRecordTypeFromId | | | |
91+
| objectName, Set<recordTypeDevName> | | | | getRecordTypeIdSetFromDevNames |
92+
| objectName | | getRecordTypeDevNameIdMap | | |
93+
| objectName | | getRecordTypeNameIdMap | | |
94+
| objectName | | getAvailableRecordTypeDevNameIdMap | | |
95+
| objectName | | getAvailableRecordTypeNameIdMap | | |
96+
| objectName | | | getRecordTypesForSelectList | |
97+
| objectName | | | getAllRecordTypesForSelectList | |
98+
| objectName | | | getStringRecordTypesForSelectList | |

apexdox.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ engine:
2020
homePagePath: "${workspaceFolder}/doc-assets/main.html"
2121
pages:
2222
- "${workspaceFolder}/doc-assets/changelog.html"
23-
23+
#- "${workspaceFolder}/doc-assets/RecordTypesHome.html"
2424
assets:
2525
- "${workspaceFolder}/doc-assets/logo.png"
2626
- "${workspaceFolder}/doc-assets/favicon.png"
@@ -30,7 +30,6 @@ engine:
3030
- "${workspaceFolder}/doc-assets/index.css"
3131
- "${workspaceFolder}/doc-assets/highlight.js"
3232
- "${workspaceFolder}/doc-assets/index.js"
33-
#- "${workspaceFolder}/doc-assets/RecordTypesHome.html"
3433

3534
port: 8080
3635
docblock:

doc-assets/RecordTypesHome.html

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)