Sub topic 11
When Native Salesforce Tools Are Enough
This chapter assumes you know Salesforce objects and records, can read Apex or Flow, and understand REST and JSON. It covers the signals that tell you a native build is the right choice, and the mistakes that make a native build fail.
Signals that native is enough
Native tools usually suffice when most of these are true:
- Few endpoints. Salesforce talks to one or two systems, and no third system needs the same data.
- Simple pattern. The integration is request-reply or fire-and-forget, such as fetching an order status or notifying a system of a change.
- Light transformation. Field mapping is mostly one-to-one and fits in a Flow or a short Apex method.
- Modern interface. The other system exposes REST with OAuth or an API key, so a Named Credential can hold the endpoint and authentication.
- Moderate volume. Calls stay well inside API and governor limits.
- Salesforce skills. The people who will maintain it already know Flow and Apex.
The native toolkit in practice
A Named Credential keeps endpoints and secrets out of code. An Apex callout, or a Flow HTTP Callout action, then uses it. For event-style needs, publish a Platform Event or use Change Data Capture and let subscribers react. For read-only access to external data, Salesforce Connect shows it as external objects without copying it.
The code below fetches an order from an ERP system. It handles failures instead of assuming a 200 response.
public with sharing class OrderStatusService {
public class IntegrationException extends Exception {}
public static String getStatus(String orderId) {
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ERP_Credential/orders/' + EncodingUtil.urlEncode(orderId, 'UTF-8'));
req.setMethod('GET');
req.setTimeout(10000);
HttpResponse res = new Http().send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> order = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
return (String) order.get('status');
}
if (res.getStatusCode() == 404) {
return null;
}
throw new IntegrationException('ERP returned ' + res.getStatusCode());
}
}Here the credential holds the secret, the timeout is explicit, and the "not found" and "error" cases are separate. For a single request-reply integration, this is often all you need.
How to check your case
Common errors in native builds
Native does not mean careless. Watch for these:
- Callout after DML in the same transaction. Salesforce raises an "uncommitted work pending" error. Make the callout first, or move it to a Queueable class that implements
Database.AllowsCallouts. - Hardcoded endpoints and credentials. Use Named Credentials so you can change them per environment without a deployment.
- No retry or logging. A failed callout in a trigger disappears unless you record it. Write failures to a custom log object and retry from a scheduled or Queueable job.
- Ignoring limits. A transaction allows 100 callouts, and the callouts together may not exceed 120 seconds. Bulk record changes can hit these quickly.
Why native is worth defending
A native build has no extra platform to license, deploy, or monitor. It uses one security model and one set of admins. Choosing middleware "just in case" adds cost and a new failure point for an integration that never needed it.
Exercise
A support team wants Salesforce to show the live shipping status from one carrier's REST API on the Case page. About 200 lookups run per day, and the response needs one field mapped. List two reasons native tools are enough, and one change in requirements that would make you reconsider.
Show answer
Reasons: there is a single endpoint with a simple request-reply pattern, and the volume and mapping are small, so a Named Credential with an Apex callout or Flow HTTP Callout fits within limits and the team's skills. Reconsider if more systems need the same carrier data, if volume grows toward API or callout limits, or if the carrier requires protocol or data transformation that is awkward in Apex.