Promises
The promises.
OnSuccess
A formula fragment that is run when the first promise succeeds. The result returned by this promise is available under the name Result and the position of this promise in the promises array is available under the name Index .
OnFailure
A formula fragment that is run if all promises fail. The errors returned by the promises are available as an array under the name Errors . Refer to the documentation for the action functions returning the promises to learn what information is available on individual errors. Use INDEX to retrieve them.
Returns
A promise, which succeeds when the first of the given promises succeeds and fails if all of the given promises fail. If the promise succeeds, the returned value is the result of the promise that succeeded. If the promise fails, the returned value is an array of all the errors returned by the promises.
Waits for the first of multiple promises to succeed before running an action. This function can only be used from an action formula. AWAITANY and other similar functions are used to take action when a promise succeeds or fails.
The first parameter to AWAITANY must be an array of promises . A function returning such a value promises to return a value at some point in the future, or at the very least indicate whether the operation the function started was successful. A promise either succeeds or fails, and it can only succeed or fail once.
AWAITANY runs the formula fragment given as its second parameter as soon as a promise given to it succeeds. The result returned by this promise is available under the name Result and the position of this promise in the promises array is available under the name Index .
The formula fragment given as the third parameter to AWAITANY is only run if all promises fail. If that is the case, the errors returned by the promises are available as an array under the name Errors .
This is different from how AWAITRACE works. Both functions perform identically when handling promises that succeed, but handle errors differently. AWAITRACE does not wait for all promises to fail before running the formula fragment given as its third parameter, it invokes it immediately once the first promise to return a result has failed. AWAITANY, on the other hand, waits for all promises to fail before invoking the formula fragment given as its third parameter.