function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
__sandra____sandra__ 

Apex callouts design

I would like to know what are the main differences between :

 

synchronous callouts and asychronous callouts

 

callouts in trigger, in batch and in a VF contoller

 

 

 

because I want to design a solution for the following requirement and I really dont khow what would be the appropried design :

 

Before inserting a new record for a cutom object, I want to do many synchronous callouts to gather some information, and  depending on these information I have to update some of my record's fields before inserting it.

 

 

 

I have thought about making this in a before insert trigger, but it seems that triggers do not support synchronous callouts.

 

Thank you!

AmitSahuAmitSahu

1. Write callout in a apex class (@future(callouts=true))...

2. Call the future method in trigger to get information from other server.

3. Use before trigger to populate the field before the record is inserted..

__sandra____sandra__

Thank you, but using an asynchronous call in a trigger means that the trigger does not stop until the callout response is received.

 

So can the record be inserted before getting the callout response?

 

Because I have to do some changes on the record fields based on the callout response before inserting the record.

 

Thank you!