Create a Query Using a Specific Record Field

The following sample creates a query for records using the value of the operationdisplaytext field. If you run this sample in your account, be sure to replace the placeholder value <transactionId> with a valid value from your account.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
* @NApiVersion 2.x
*/
require(['N/query'], function(query) {
    var mfgComponent = query.create({
        type: query.Type.MANUFACTURING_COMPONENT
    });

    var mfgOperation = mfgComponent.autoJoin({
        fieldId: 'operationdisplaytext'
    });

    mfgComponent.columns = [
        mfgComponent.createColumn({
            fieldId: 'operationdisplaytext'
        }),
        mfgComponent.createColumn({
            fieldId: 'item'
        }),
        mfgOperation.createColumn({
            fieldId: 'operationsequence'
        })
    ];

    mfgComponent.condition = mfgComponent.and(
        mfgComponent.createCondition({
            fieldId: 'transaction',
            operator: query.Operator.ANY_OF,
            values: <transactionId>
        }),
        mfgOperation.createCondition({
            fieldId: 'operationsequence',
            operator: query.Operator.EQUAL,
            values: 20
        })
    );

    var results = mfgComponent.run();
}); 

        

General Notices