Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Timeout Parameter for Asynchronous Calls

If an asynchronous call does not complete in an appropriate amount of time, you can end the call. To do this, specify the timeout parameter in the callback section of any asynchronous call.
1var account = new sforce.SObject("Account");
2account.Name = "my new account";
3
4sforce.connection.create([account], {onSuccess: print, onFailure: printerr, timeout: 100});

Values for this parameter are in milliseconds, and valid values are integers beginning with 1.

If the call is successful within the time specified by the callout, no additional actions are taken. If the call is not successful, the onFailure action is performed.

Use this parameter with caution. Because the timeout is performed on the client side, it is possible that the call may complete on the server but the timeout is still triggered. For example, you might issue a create call to create 100 new accounts, and any number of them, 1 or 100, might be created just before the timeout is triggered; your onFailure action would still occur, but the accounts would have been created.

Warning