From 3487d30d100d3ae238d0bb8c88671845c1647993 Mon Sep 17 00:00:00 2001 From: David Schach <636977+dschach@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:58:43 -0700 Subject: [PATCH] fix: remove redundant methods, update docs (#66) --- README.md | 4 +- apexdox.yml | 3 +- doc-assets/RecordTypesHome.html | 2 +- doc-assets/main.html | 245 +++++++++++++++--- doc-assets/methodstable.html | 187 +++++++++++++ doc-assets/setupApexDox.sh | 1 + docs/RecordTypes.html | 143 ++++------ docs/RecordTypesHome.html | 17 +- docs/RecordTypesTest.html | 12 +- docs/assets/RecordTypesHome.html | 211 +++++++++++++-- docs/assets/search-idx.js | 6 +- docs/changelog.html | 2 +- docs/index.html | 206 ++++++++++++++- .../main/default/classes/RecordTypes.cls | 37 +-- .../main/default/classes/RecordTypesTest.cls | 6 +- 15 files changed, 876 insertions(+), 206 deletions(-) create mode 100644 doc-assets/methodstable.html diff --git a/README.md b/README.md index af33715..7e3043d 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ This is a project based on work by [Evan Callahan](https://github.com/groundwired) (formerly of Groundwire, and now at Salesforce) who wrote [this class](https://github.com/SalesforceFoundation/JenkinsTesting/blob/master/src/classes/RecordTypes.cls) (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. diff --git a/apexdox.yml b/apexdox.yml index 1adf427..c019b6c 100644 --- a/apexdox.yml +++ b/apexdox.yml @@ -20,7 +20,7 @@ engine: homePagePath: "${workspaceFolder}/doc-assets/main.html" pages: - "${workspaceFolder}/doc-assets/changelog.html" - - "${workspaceFolder}/doc-assets/RecordTypesHome.html" + assets: - "${workspaceFolder}/doc-assets/logo.png" - "${workspaceFolder}/doc-assets/favicon.png" @@ -30,6 +30,7 @@ engine: - "${workspaceFolder}/doc-assets/index.css" - "${workspaceFolder}/doc-assets/highlight.js" - "${workspaceFolder}/doc-assets/index.js" + #- "${workspaceFolder}/doc-assets/RecordTypesHome.html" port: 8080 docblock: diff --git a/doc-assets/RecordTypesHome.html b/doc-assets/RecordTypesHome.html index fd9e17a..ff84381 100644 --- a/doc-assets/RecordTypesHome.html +++ b/doc-assets/RecordTypesHome.html @@ -16,7 +16,7 @@

Additional/Changed Header

-->

Updated by David Schach, copyright (c) 2021 X-Squared on Demand
- This class is allows for easy, readable access to Record Type information from other classes. + This class allows for easy, readable access to Record Type information from other classes.
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). diff --git a/doc-assets/main.html b/doc-assets/main.html index 7bbb540..8bd2f34 100644 --- a/doc-assets/main.html +++ b/doc-assets/main.html @@ -12,60 +12,237 @@

Record Types Utilities

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.

-

Updated by David Schach, copyright (c) 2021 X-Squared on Demand -
- This class is allows for easy, readable access to Record Type information from other classes. + This class allows for easy, readable access to Record Type information from other classes.
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).

+

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!

+

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!

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.

Badges

-

- License: GPL v3 - codecov - CI - Twitter -

+

License: GPL v3 +codecov +CI +Scratch Org +Twitter

The Code

The class and test class are found in this folder. Feel free to copy/paste directly into your org.

Documentation

ApexDox (generated with ApexDox)

Installation

-

Changelog

+ + +

Most Common Methods

+

+ 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 soem 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. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameters / OutputIdNameDeveloperName
objectName, recordTypeNamegetRecordTypeIdFromName
objectName, recordTypeNamegetRecordTypeDevNameFromName
objectName, recordTypeDevNamegetRecordTypeFromDevName
objectName, recordTypeDevNamegetRecordTypeNameFromDevName
objectName, recordTypeDevNamegetRecordTypeIdFromDevName
objectName, recordTypeIdgetRecordTypeNameFromId
objectName, recordTypeIdgetRecordTypeDevNameFromId
recordTypeIdgetRecordTypeNameFromId
recordTypeIdgetRecordTypeDevNameFromId
+ +

Less Common Methods

+

+ These methods are used less often but may be useful. +
+ 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. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameters / OutputSchema.RecordTypeInfoMap(String, Id)SelectListSet<Id>
objectName, recordTypeIdgetRecordTypeFromId
objectName, Set<recordTypeDevName>getRecordTypeIdSetFromDevNames
objectNamegetRecordTypeDevNameIdMap
objectNamegetRecordTypeNameIdMap
objectNamegetAvailableRecordTypeDevNameIdMap
objectNamegetAvailableRecordTypeNameIdMap
objectNamegetRecordTypesForSelectList
objectNamegetAllRecordTypesForSelectList
objectNamegetStringRecordTypesForSelectList
diff --git a/doc-assets/methodstable.html b/doc-assets/methodstable.html new file mode 100644 index 0000000..d0dfb12 --- /dev/null +++ b/doc-assets/methodstable.html @@ -0,0 +1,187 @@ + +

Most Common Methods

+

+ 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 soem 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. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameters / OutputIdNameDeveloperName
objectName, recordTypeNamegetRecordTypeIdFromName
objectName, recordTypeNamegetRecordTypeDevNameFromName
objectName, recordTypeDevNamegetRecordTypeFromDevName
objectName, recordTypeDevNamegetRecordTypeNameFromDevName
objectName, recordTypeDevNamegetRecordTypeIdFromDevName
objectName, recordTypeIdgetRecordTypeNameFromId
objectName, recordTypeIdgetRecordTypeDevNameFromId
recordTypeIdgetRecordTypeNameFromId
recordTypeIdgetRecordTypeDevNameFromId
+ +

Less Common Methods

+

+ These methods are used less often but may be useful. +
+ 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. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameters / OutputSchema.RecordTypeInfoMap(String, Id)SelectListSet<Id>
objectName, recordTypeIdgetRecordTypeFromId
objectName, Set<recordTypeDevName>getRecordTypeIdSetFromDevNames
objectNamegetRecordTypeDevNameIdMap
objectNamegetRecordTypeNameIdMap
objectNamegetAvailableRecordTypeDevNameIdMap
objectNamegetAvailableRecordTypeNameIdMap
objectNamegetRecordTypesForSelectList
objectNamegetAllRecordTypesForSelectList
objectNamegetStringRecordTypesForSelectList
diff --git a/doc-assets/setupApexDox.sh b/doc-assets/setupApexDox.sh index 4ede63e..f275fc0 100644 --- a/doc-assets/setupApexDox.sh +++ b/doc-assets/setupApexDox.sh @@ -7,6 +7,7 @@ echo >> "doc-assets/main.html" cat doc-assets/RecordTypesHome.html >> "doc-assets/main.html" echo "\n" >> "doc-assets/main.html" npx marked -i README.md --gfm >> "doc-assets/main.html" +cat doc-assets/methodstable.html >> "doc-assets/main.html" printf '' > "doc-assets/changelog.html" #echo >> "doc-assets/changelog.html" diff --git a/docs/RecordTypes.html b/docs/RecordTypes.html index d5894a0..57ecfad 100644 --- a/docs/RecordTypes.html +++ b/docs/RecordTypes.html @@ -39,7 +39,7 @@
- RecordTypes + RecordTypes