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
Inbox OutboxInbox Outbox 

Do we use both asynchornous and also synchronous callouts?

Sunshine!
Do we use both synchonous and asynchronous callouts for external web services? When do we use synchronous and when do we use asynchronous?
Please give me some examples or scenarios. 

 
Best Answer chosen by Inbox Outbox
Suraj Tripathi 47Suraj Tripathi 47
Hi,

Greetings!

From Apex SOAP, You can callout synchronously, When there is a dependency on data then you will use synchronously callout.
From future methods,You can callout asynchronously, When there is no dependency on data.

If you find your Solution then mark this as the best answer. 
Thank you!
Regards,
Suraj Tripathi

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi there,

>> https://www.jitendrazaa.com/blog/tag/asynchronous-apex/

The above link has implementations that you can try checking once.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Suraj Tripathi 47Suraj Tripathi 47
Hi,

Greetings!

From Apex SOAP, You can callout synchronously, When there is a dependency on data then you will use synchronously callout.
From future methods,You can callout asynchronously, When there is no dependency on data.

If you find your Solution then mark this as the best answer. 
Thank you!
Regards,
Suraj Tripathi
This was selected as the best answer
Inbox OutboxInbox Outbox
Thank you guys for the reply. 

1. I was wondering why we use conditional boolean context variables like isInsert, isbefore when we already mention the DML events (before insert) in the trigger parameter!
2. Can we track the queuable job progress from whithin the same trigger which invokes?
Suraj Tripathi 47Suraj Tripathi 47
For best practices, there should be only a trigger for one object.
So when we create only one trigger for an object, We have to add all the events in the trigger parameter.

Now, your trigger code will run a number of times of events parameters.
So we have to decide which method will run on before insert and which method is run on after insert.
So we use isAfter and isBefore context variable to check for which event our code is running.

I've also answered your another query regarding same question. 
https://developer.salesforce.com/forums?id=9062I000000DJipQAG

If that also helped you please mark that also as the best answer.
Thank you!

Regards,
Suraj Tripathi