R1D43 Getting Hands Dirty with Apex
I started my Salesforce Trailhead journey so that I could solve real problems that we have on my team. I took everything that I learned over the last few weeks and started working on one of those problems.
Like most things in life, everything looks very simple when you see it presented in a tutorial format, and then when you start to get in the weeds things become a bit more complicated.
The problem that I am trying to solve is to send some data to a third party service any time a deal closes. This requires thinking about a few things.
- Ensuring validation when the state of an opportunity changes to closed won.
- Firing off an event when that happens.
- Taking the data from the opportunity and formatting it properly as JOSN to send to the third party system.
- Find all the files attached to the opportunity (this turned out to be a rabbit hole of epic proportions.)
- Firing off the HTTP POST to the third party system. This includes figuring out some sane way to store the token safely.
Notably:
- Very handy JSONGenerator class that makes it very easy to create well formatted JSON objects.
- Static typing takes some getting used to.
- Apex does not support multiline string formatting out of the box so you have to do things the old fashioned way.
String descriptionTemplate =
'Account Name: {0}\n' +
'Account Email: {1}\n' +
'Plan: {2}\n' +
'Plan Description: {3}\n' +
'Invoice Amount: {4}\n' +
'Invoice Frequency: {5}\n';
I am looking forward to wrapping this up and moving on to the next, slightly more complicated problem that I am trying to solve with Salesforce.
Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.
Check out some more stuff to read down below.
Most popular posts this month
- Great Lakes, Illinois
- Are we inside a Sarlacc?
- My Custom Miniflux CSS Theme
- Setting up ANTLR4 on Windows
- Vagrant Box for ROS2 on Apple Silicon
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- Grow, Like a Tree Not a Cancer from Jim Nielsen’s Blog
- Pluralistic: All the books I reviewed in 2025 (02 Dec 2025) from Pluralistic: Daily links from Cory Doctorow
- DEP-18: A proposal for Git-based collaboration in Debian from Optimized by Otto
- [RIDGELINE] No Phones in The Ten-don Shop from Craig Mod — Writer + Photographer
- My next chapter with Mastodon from Mastodon Blog
- How many pillars of observability can you fit on the head of a pin? from charity.wtf
- The Software Essays that Shaped Me from Refactoring English
- Give Your Spouse the Gift of a Couple's Email Domain from mtlynch.io
Articles from blogs I follow around the net
Moving from WordPress to Substack
Well, shit. I wrote my first blog post in this space on December 27th, 2015 — almost exactly a decade ago. “Hello, world.” I had just left Facebook, hadn’t yet formally incorporated Honeycomb, and it just felt like it was time, long past time for me to pu…
via charity.wtf December 14, 2025Pluralistic: Federal Wallet Inspectors (13 Dec 2025)
Today's links Federal Wallet Inspectors: Does tech *really* move too fast to regulate? Hey look at this: Delights to delectate. Object permanence: Soda can Van de Graff; Amazon rents a copy of the web; Boardgame Remix Kit; No furniture photos please w…
via Pluralistic: Daily links from Cory Doctorow December 13, 2025Solving Advent of Code 2025 in Janet: Days 5–8
I’m solving the Advent of Code 2025 in Janet. After doing the last five years in Haskell, I wanted to learn a new language this year. I’ve been eyeing the “New Lisps”1 for a while now, and I decided to learn Janet. Janet is a Clojure like Lisp that can be …
via Programming Posts & Notes on abhinavsarkar.net December 13, 2025Generated by openring