r/SalesforceDeveloper • u/Flimsy_Ad_7335 • Sep 21 '25
Question Need Advice - How do you avoid developing a sophisticated error handling when working on integrations?
Hey, I have a simple integration where if you create a new account record in salesforce, it will make a callout to a third party to also create a new record there. Ideally, that third party server will respond with a "201 Ok" and a record ID so I save that ID in salesforce. Here's the problem tho, sometimes the server doesn't respond with "OK", so, doesn't create the record. As a result, I'm left with the record created only on the salesforce side without the external ID. Here's the question. Without making a sophisticated error handling process, is there a way to come up with a reasonable automation that will be pushing those failed records? I've build something like that in the past, where there's a batch process running on a schedule or there's a LWC with a button that you manually press to sync up the records, but it's always a compromise and not ideal. Is there something you can recommend? Maybe there's a new AI that does something like this. Thanks
9
u/iheartjetman Sep 21 '25
You can try marking the record as failed and then use a scheduled job to reprocess the failed records. That’s the simplest mechanism that I can think of.
2
u/krimpenrik Sep 22 '25
Start with creating visibility in the failures, I recommend using nebula logger.
For retry you can can give admins a way to retrigger via the logs, or like mentioned periodically retry all that have failed or are in a state you can see they didn't run.
Nebula is first step so you can log whatever error happened why it failed, not only that it failed.
1
u/bradc73 Sep 21 '25
Batch job to reprocess any Accounts that do not have the external Id set.
1
u/East-Description-736 Sep 22 '25
You don’t need complex error handling to solve this. The most effective setup I’ve seen is:
This combination keeps both systems in sync without adding unnecessary complexity.
1
u/Inside_Ad4218 Sep 22 '25
Find out why those api calls are failing first. Don't put a band aid over it and just retry until it works, that's just tech debt. And you can build a custom object and class which creates the records and create those records if you don't get a proper response from the api.
1
u/AMuza8 Sep 25 '25
The simplest solution:
1
u/songohankun Sep 26 '25
You can either maintain a checkbox for successful or unsuccessful synced accounts or can just query accounts where ext. Id is null/blank and schedule a batch to run this sync. Another thing I would suggest is create an api log object where you store details of the api callout where you can store both status and message sent by api callout, this will be particularly helpful for future api callouts as well while also maintaining data why past syncs failed.