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
sfdc_syedsfdc_syed 

What is the differene b/w asynchronous call and synchronous call ?

What is the differene b/w asynchronous call and synchronous call ?

sfdcfoxsfdcfox

Synchronous means that your code waits while the transaction is processing, while asynchronous means your program is notified when the transaction is complete (it can continue to perform other actions while waiting).

 

Synchronous:

 

// No data is available yet.
result = sforce.connection.query(...)
// The data is now available.

 Asynchronous:

 

// No data is available yet
sforce.connection.query( ... { onSuccess: processResults, onFailure: displayErrors } )
// Data is still not available.
// But I can do other stuff while I wait, like rendering a spinner.

function processResults(results) {
  // The data is now available.
}

It is generally advantageous to use asynchronous methods, as the user can get immediate feedback about the progress, and can continue to work when there is a long delay, such as loading tens of thousands of records. Synchronous actions tend to make the browser or application "freeze" while the results are being processed, which can frustrate the user if there is a long delay.