The following sample creates a query for customer records, converts it to its SuiteQL representation, and runs it.
/**
* @NApiVersion 2.x
*/
require(['N/query'], function(query) {
var myCustomerQuery = query.create({
type: query.Type.CUSTOMER
});
myCustomerQuery.columns = [
myCustomerQuery.createColumn({
fieldId: 'entityid'
}),
myCustomerQuery.createColumn({
fieldId: 'email'
})
];
myCustomerQuery.condition = myCustomerQuery.createCondition({
fieldId: 'isperson',
operator: query.Operator.IS,
values: [true]
});
var mySQLCustomerQuery = myCustomerQuery.toSuiteQL();
var results = mySQLCustomerQuery.run();
});