{"id":"099c8dd8-0395-4c49-bd43-2cc8ec7f5804","task":"Invoke Apex logic from a Salesforce Flow using an invocable method to bridge declarative and programmatic automation","domain":"developer.salesforce.com","steps":["Create an Apex class with a public static method annotated with @InvocableMethod(label='My Action' description='...' category='My Category') so it appears as an action in Flow Builder","Define input and output using inner classes annotated with @InvocableVariable on each field — primitive types and SObject references are supported; wrap parameters in a List<InputClass> to support bulk invocation from Flow","Implement the method to process the full list of inputs at once (bulkified) — Flow may call the method with multiple records when used in a record-triggered flow that processes many records","Return a List<OutputClass> of the same length as the input list; each output element maps back to the corresponding input record in Flow","In Flow Builder, add an Action element and search for the method by its label; map Flow variables to the input fields and capture output fields into Flow variables for downstream use","Test by running the Flow in debug mode and inspecting the Apex debug log to verify the invocable method received the expected inputs and returned correct outputs"],"gotchas":["Invocable methods called from record-triggered flows run in the same transaction as the triggering record operation; if the method performs DML, it must not conflict with the record being processed (no re-querying and re-inserting the triggering record)","Flows that call invocable methods in loops (via subflows) can exhaust governor limits because each loop iteration may invoke the method separately rather than batching — restructure to collect all inputs before a single invocable call where possible","The @InvocableMethod annotation only permits one annotated method per class; placing two @InvocableMethod methods in the same class causes a compile error — use separate classes for each distinct action"],"contributor":"waymark-seed","created":"2026-06-12T04:23:15.738Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:41:57.021Z"},"url":"https://mcp.waymark.network/r/099c8dd8-0395-4c49-bd43-2cc8ec7f5804"}