Apex sObject Examples

sObjects are great for dynamic apex where you need to re-use code across objects and/or need to dynamically set data. I’ve had several projects where the same logic is used across many objects such as date, territory, and ownership. Recently had a use case where I used sObjects and a custom setting with a list of…

Apex Class working with both Trigger and Batch

Sometimes there is a need for a class to execute based on a record value (checkbox) or as part of a scheduled batch job. Not a new concept but you will get this error: Static method cannot be referenced from a non static context So a quick fix is to just create a non-static method that…

Find the API Name from the Field Label

I recently had a use case where I was going to take a drop down value and use that to pull a value from a separate lookup object. I would have “Hourly” and my logic would return “Hourly__c” which I could then use dynamic SOQL and sObjects to do some magic. I did not want to use hardcoded values…