Skip to main content
9 votes
Accepted

Best approach to make callouts from trigger

I wrote an article about this sort of requirement for ApexHours, which you'll find here. The key points are: Futures are a real problem to be called from a trigger because you cannot invoke/enqueue a ...
Phil W's user avatar
  • 36.8k
6 votes

getting a 'Missing return statment required' even though i have one

You're missing the return statement for when you don't satisfy the if condition and also don't satisfy the else if condition. The code inside your else if is unreachable (because 3 > 5 will always ...
Derek F's user avatar
  • 62.3k
6 votes

How to make a call out after every DML in batch

The basic answer is "you can't." DMLs block callouts, so if you need this kind of behavior, you have to arrange an alternative solution. I solved this very problem in a different manner once....
sfdcfox's user avatar
  • 495k
5 votes
Accepted

GCP created SObject is not immediately available in apex

There is a small, but non-zero, delay where the record might not yet be available outside of the transaction that created it, since sharing and other calculations are deferred outside of the ...
sfdcfox's user avatar
  • 495k
3 votes

How to make a call out after every DML in batch

The obvious answer is to invoke a future method or enqueue a Queueable that does the callout. You'd call or enqueue with the required details after each DML in execute. Obviously the future method or ...
Phil W's user avatar
  • 36.8k
3 votes

Scenarios to use Platform Events

In addition to the other comments, Platform Events are an ideal way to change the running user. Using the metadata type PlatformEventSubscriberConfig you can define the running user to be (typically) ...
cropredy's user avatar
  • 71.9k
3 votes
Accepted

Weird "common.apex.runtime.impl.ExecutionException: Syntax error"|0x78b85a0a while doing a Callout

I was able to figure it out. As the hint of the last character was giving it turns out that I had checked by mistake the Allow Formulas in HTTP Body in the Named Credentials definition. So because I ...
ymiki's user avatar
  • 73
3 votes

External Credential's 'Principal' not allowing multiple parameters

Have been doing quite some development with External Credentials and this this seem to be the normal process. My best guess is that this is salesforce way to make the parameters secure by making them ...
Erlend Hansen's user avatar
3 votes
Accepted

Is it guaranteed that First submitted Queueable or Batch class will run first?

Given that there are no documented guarantees around order of execution for Queueable implementations (these do not go into a queue in the same way that Batchables do), I would consider creating a &...
Phil W's user avatar
  • 36.8k
2 votes
Accepted

System.Formula.recalculateFormulas triggers DML statement while running unit tests

I reported this issue to Salesforce support, and they created a bug ticket: Known Issues: In test classes, Formula.recalculateFormulas() is causing error "System.CalloutException: You have ...
Francis Huang's user avatar
2 votes

Scenarios to use Platform Events

In addition to the points in other answers, Platform Events can be used to perform what is effectively asynchronous processing outside the initiating transaction in a sequential (or narrowly ...
Phil W's user avatar
  • 36.8k
2 votes

Scenarios to use Platform Events

Event-driven architecture tends to be a more efficient method of communicating between systems. This is because the subscribers don't have to continually check for updates (polling), publishers don't ...
sfdcfox's user avatar
  • 495k
2 votes

Unable to make web callout even after Database.rollback

In Spring `24 we added the ability in Apex to explicitly release a savepoint. After release the callout will be permitted. See Make Callouts After Rolling Back DML and Releasing Savepoints Savepoint ...
Daniel Ballinger's user avatar
2 votes
Accepted

'uncommitted work pending' even when all DML statements have been deactivated

Googling for the error gives lots of suggestions, such as moving the call-out to a future method, or collecting all DMLs and perform them after the call-out. But I had disabled all DML statements, so ...
Sander de Jong's user avatar
2 votes

I have a trigger that makes callout to external system in a future(callout=true) but does not run immediately. Where is this callout queued?

This is expected behavior. Going async (future, batch, schedulable, queueable, platform event) means you're letting Salesforce execute things when they determine they have the resources available to ...
Derek F's user avatar
  • 62.3k
2 votes

Named Credentials in Managed Package Apex Callout

It seems that it is not possible for a managed package to use a named credential that is created outside the managed package's code, as per the documentation: Managed packages can access only the ...
Phil W's user avatar
  • 36.8k
1 vote
Accepted

Best way to update thousands of records with callouts in Salesforce

I have a lot of feedback regarding this code, so most of this is answered with inline comments. If you're getting "too many callouts," then your scope isn't working correctly. Having a scope ...
sfdcfox's user avatar
  • 495k
1 vote

I want to write a unit test that can assert an enqueued job called a specific @Future function

Static variables persist across an entire unit test, so one easy design is: public class Utils { @TestVisible static Boolean makeCalloutCalled = false; @future(callout=true) public static void ...
sfdcfox's user avatar
  • 495k
1 vote

Access Named Credentials with Guest User

Based on the response from @cropredy I enabled Create and Read Permissons for the User External Credentials Object and the Guest User can now access the Named Credential!
Jeff Callahan's user avatar
1 vote

Unrecognized base64 character

The important clue here is Unrecognized base64 character: { You're getting a JSON response from the DocuSign api, not a Base64 one. It's not clear what that JSON looks like because I can't find the ...
Derek F's user avatar
  • 62.3k
1 vote
Accepted

http call out to an external REST webservice

One step which you have missed is adding apex class permissions for permission set you created. If you know the request and response, but api is still under development, use postman(or any mock api) ...
vivekvismayam's user avatar
1 vote

Best approach to make callouts from trigger

Use a trigger on Account to publish a Platform Event, e.g. Account_Update__e. Use an after insert trigger on Account_Update__e to call a @future(callout=true) method to call your API. If possible, ...
xn.'s user avatar
  • 2,468
1 vote

Scenarios to use Platform Events

Are there any scenarios where platform events are the only option to choose from? As far as I know there isn't any. Mainly because platform events are based on Streaming API which is existing already ...
user1974566's user avatar
  • 2,315
1 vote
Accepted

Scenarios to use Platform Events

Take the scenario where Salesforce needs to publish an event when a certain thing happens. Salesforce announces - as the Publisher in the Pub-Sub system - that something happened, and this event ...
Renato Oliveira's user avatar
1 vote
Accepted

Making a lot of chained API calls in Apex

You can query the external API for the first header data, create Salesforce records for those, and then use a batch job to iterate those records and do your multiple callouts for each piece of data. ...
Renato Oliveira's user avatar
1 vote

Callout failed for invocable action

I had the same problem as you. The issue was resolved by assigning read permission on the "User External Credentials" in the "Object Settings". You can assign this directly in your ...
Claudeilto Brito Dias's user avatar
1 vote

Cannot see Http Callout in Flows

HTTP Callout is Available in: Lightning Experience Enterprise, Unlimited, and Developer Editions. In Flow Builder, dragging the Action Element on to the canvas exposes the Action modal. There, you ...
Kevin Judd's user avatar
1 vote

Deserializing is giving null values from wrapper classes

The reason this isn't working is because your responsebody doesn't match up with your class. Your responsebody has an extra layer to it. It has 2 properties: http_status_code response Your class ...
Nick C's user avatar
  • 6,780
1 vote
Accepted

Convert or parse datetime coming from external system and save it in salesforce

1. Determine the Timezone Offset: Since CST (Central Standard Time) does not specify whether it's Central Standard Time in the USA or China (they have different offsets), you need to know the specific ...
sahil kakadiya's user avatar
1 vote
Accepted

Send 1 Million records data to external system using batch class

Answering your questions, assuming you fix the issues with your sample code: The code will work for 1 million records. Using the maximum batch size of 2000, your code will run 500 times and do 500 ...
fred's user avatar
  • 3,420

Only top scored, non community-wiki answers of a minimum length are eligible