n/query module sample to get Sales order data specific internal id

define([‘N/query’]

(query){

let myQuery = query.create({

                    type: query.Type.TRANSACTION

                });              

                var firstCondition = myQuery.createCondition({

                    fieldId: ‘recordtype’,

                    operator: query.Operator.ANY_OF,

                    values: “salesorder”,

                    caseSensitive: true

                });

                let secondCondition = myQuery.createCondition({

                    fieldId: ‘id’,

                    operator: query.Operator.EQUAL,

                    values: scriptContext.newRecord.id

                });                

                myQuery.condition = myQuery.and(firstCondition,

                    myQuery.and(firstCondition, secondCondition)

                );

                myQuery.columns = [

                    myQuery.createColumn({ fieldId: ‘tranid’ }),

                    myQuery.createColumn({ fieldId: ‘id’ }),

                    myQuery.createColumn({ fieldId: ‘transactionlines.item’ })

                ];              

                let results = myQuery.run();

                log.debug(‘Sales Order Info’, results);

}

Leave a comment

Your email address will not be published. Required fields are marked *