I’ve had a pleasure to watch many Salesforce technical architects trying to find a perfect way, how to work with Record Types in Apex . One created class Global_Constants to store all Record Type Ids and DeveloperNames in static properties, the other queried RecordType table and put the result in the map. I was never impressed so I‘ve come up with Record Type Provider , that allows you to access RecordTypeId like this: RecordTypeProvider.[ObjectName].[RecordTypeName].Id . It’s not perfect, but it definitely has its pros. What doesn’t work First, I would like to stop by the usual solutions and explain, why they do not work (well). Querying the RecordType table is extremely fast – you get all the Record Type descriptions in few miliseconds, but on the other hand you lose what every Salesforce developer must treasure the most – SOQL query . You may think, that you have only limited amount of classes and this one tiny query will never mean anything, but over time logic in your o
Solutions, implementation tips, benchmarks and news from the world of Salesforce especially focused on technical side of things.