AI Tool Calling Pattern for Salesforce Apex
How to implement AI tool calling (function calling) in Salesforce Apex, working around the DML-before-callout transaction limitation with a multi-transaction follow-up pattern.
How to implement AI tool calling (function calling) in Salesforce Apex, working around the DML-before-callout transaction limitation with a multi-transaction follow-up pattern.
How to pull, manage, and analyze Salesforce Apex debug logs using SFDX CLI and Claude Code for fast root cause diagnosis.
Core Apex programming — classes, interfaces, triggers, governor limits, and order of execution.
How to split expensive processing between a synchronous Invocable method and an asynchronous Queueable job to avoid the 15-second CPU time limit.
How to design @InvocableMethod and @InvocableVariable classes that bridge Apex power with Flow Builder's declarative ease-of-use.
How trigger-based default field logic can interfere with record cloning, and patterns to detect and handle clone operations safely.
Strategies for managing multi-turn LLM conversation token costs by compacting older messages into summaries while preserving context continuity.
How to create Credit Memos using the Salesforce Commerce Invoicing REST API from Apex, including Named Credentials, request formatting, and cascading updates.
Using Custom Metadata Types to externalize AI chatbot configuration -- model settings, behavior rules, and UI prompts -- with cached Apex queries and fallback defaults.
When Database.upsert() encounters UNABLE_TO_LOCK_ROW, the error appears in UpsertResult objects — not as an exception. Without explicit handling, lock contention silently drops records.
Understanding the distinction between synchronous and asynchronous Apex execution contexts, and how to decide what runs inline vs. in a Queueable or future method.
How to use Apex wrapper (DTO) classes to transform database object shapes into UI-friendly structures for Lightning Web Components.
How to handle, propagate, and display errors consistently between Apex and LWC, including the AuraHandledException pattern and a universal error extraction utility.
How to combine timestamps and cryptographic hashing to create collision-resistant, URL-safe unique identifiers for integration transactions.
Understanding why performing DML before an HTTP callout throws an uncommitted work error, and how to structure your Apex transactions to avoid it.
Design patterns for auto-populating fields on record creation while preserving user modifications on subsequent updates.
How to structure trigger handler logic in multiple passes when later fields depend on earlier fields being resolved first.
How concurrent Queueable jobs create race conditions that lead to duplicate records, and how FOR UPDATE locking, External ID Upsert, and dedup queries provide defense-in-depth.
How to implement invoice write-offs in Salesforce Revenue Cloud using the writeOffInvoices standard action API. Covers prerequisites, Apex implementation, mechanical behavior, business use cases, and comparison with other invoice close-out methods.
How to prevent stale rollup values by initializing parent fields to zero before running aggregate queries, especially when all child records are deleted.
When cloning SObjects in Apex, partially clearing system audit fields (CreatedDate, LastModifiedDate) causes FIELD_INTEGRITY_EXCEPTION errors. All four audit fields must be cleared together.
Apex testing strategies — test classes, data factories, mocking, and deployment requirements.
How to test and debug @AuraEnabled Apex methods using Anonymous Apex, including handling AuraHandledException and DML-before-callout constraints.
How to structure Apex tests for systems where triggers enqueue Queueable jobs, including test setup patterns, async execution, and edge case coverage.
How to replace per-record SOQL queries with a single bulk query and Map-based lookups to stay within governor limits.
Understanding why Queueable jobs are serialized at enqueue time, not execution time, and how the shared key pattern prevents silent data loss.
How to accumulate record IDs across multiple trigger chunks and enqueue a single Queueable job for efficient bulk processing.
How to prevent INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST errors when AI tools create Salesforce records, by dynamically populating tool enum values from org metadata.