Query.run.promise()

Method Description

Executes the query asynchronously and returns the query result set.

Note:

The parameters and errors thrown for this method are the same as those for Query.run(). For more information about promises, see Promise Object.

Returns

Promise Object

Synchronous Version

Query.run()

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/query Module

Parent Object

query.Query

Sibling Object Members

Query Object Members

Since

2018.1

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete promise script example, see Promise Object.

            // Add additional code
...
    var myCustomerQuery = query.create({
        type: query.Type.CUSTOMER
    });
    var mySalesRepJoin = myCustomerQuery.autoJoin({
        fieldId: 'salesrep'
    });
    myCustomerQuery.columns = [
        myCustomerQuery.createColumn({
            fieldId: 'entityid'
        }),
        myCustomerQuery.createColumn({
            fieldId: 'id'
        }),
        mySalesRepJoin.createColumn({
            fieldId: 'entityid'
        }),
        mySalesRepJoin.createColumn({
            fieldId: 'email'
        }),
        mySalesRepJoin.createColumn({
            fieldId: 'hiredate'
        })
    ];
    myCustomerQuery.sort = [
        myCustomerQuery.createSort({
            column: myCustomerQuery.columns[1]
        }),
        mySalesRepJoin.createSort({
            column: mySalesRepJoin.columns[0],
            ascending: false
        })
    ];
    var resultSet = myCustomerQuery.run.promise({
        customScriptId: 'myCustomScriptId'
    }).then (function(result) {
        // Process the result
    });
...
// Add additional code 

          

Related Topics

General Notices