Create a Quality Custom Inspection Rule Plug-in

This script sample script shows how to evaluate quality inspection data and standards to determine if an inspection should pass or fail.

This script can also be found at Quality Custom Inspection Rule Echo Source as part of Quality Management Administration.

The following code is a sample implementation of a custom inspection rule plug-in.

Note:

This sample script uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript Debugger.

This implementation simply echos all inputs to the log to assist new developers and returns true.

          /**
* @NApiVersion 2.x
* @NScriptType plugintypeimpl
*
* ECHO Implementation of Custom Rule Plug-in for Quality Management SuiteApp
   */
define(['N/log'], function(log) {
      return {
         inspectionPassed: function(inspectionObj, fieldObj, otherFieldObjs, standardObjs) {
            // echo inspectionObj
            log.debug({
                     title: 'insepctionObj',
                     details: 'type:' + inspectionObj.type +
                           ' name:' + inspectionObj.name +
                           ' txnId:' + inspectionObj.txnId +
                           ' itemId:' + inspectionObj.itemId
            });

            // echo fieldObj
            log.debug({
                     title: 'fieldObj',
                     details: 'name:' + fieldObj.name +
                                    ' value:' + fieldObj.value
            });

            // echo otherFieldObjs
            for ( var i in otherFieldObjs ) { 
                     log.debug({
                                    title: 'otherFieldObjs',
                                    details: 'name:' + otherFieldObjs[i].name +
                                                   ' value:' + otherFieldObjs[i].value
                     });
            }

            // echo standardObjs
            for ( var i in standardObjs ) {
                  log.debug({
                              title: 'standardObjs',
                              details: 'name:' + standardObjs[i].name +
                                             ' value:' + standardObjs[i].value
                  });
            }
            return true;
         }
      }
}); 

        

General Notices