Not rocket science but as usual there are a lot of bad posts on this so: Switch Opportunity for whatever object and tralala.
Tag: apex
Silly Dev Trick: Converting Ids from 15 to 18 Automagically in Apex
Anyone that has dealt with Opportunity Line Items knows that you cannot create a lookup to that record on another. So the next best thing is to put a text field and store the Id. Apex stores Ids in their 18 length form but in the UI it shows it to you as 15 digits. Since…
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…
Silly Admin Trick: Finding Active ‘Frozen’ Users in Salesforce.com
One gap with freezing users in Salesforce.com is the ability to go back and find those users. Google is your friend for finding the answer. There’s even an article from Salesforce: How can I tell what Users are Frozen via the API? The below is my take on it. Use workbench/bulk/csv to create an exportable list 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…