Asynchronous Server-Side Promises

SuiteScript 2.1 fully supports non-blocking asynchronous server-side promises expressed using the asnyc, await, and promise keywords for a subset of modules: N/http, N/https, N/query, N/search, and N/transaction. See the help topic Promise Object for a list of promise methods supported in server scripts.

When using server-side promises in SuiteScript, you should consider the following:

The following code sample shows the use of the async and await keywords:

          async function() {
    let myQuery = query.load ({
        id: myQueryId
    });
    let myResult = await myQuery.run().then (function(result) {
        // do stuff
    });
} 

        

For more information about JavaScript promises, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise.

For more information about asynchronous JavaScript programming, see https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous.

For more information about the Promise object in SuiteScript, see Promise Object.

Related Topics

General Notices