Perform Field Sourcing Synchronously

The following script sample shows how to use the forceSyncSourcing parameter.

This parameter can be used to alleviate a timing situation that may occur in some browsers when fields are sourced. For some browsers, some APIs are triggered without waiting for the field sourcing to complete. For example, if forceSyncSourcing is set to false when adding sublist lines, the lines aren't committed as expected. Setting the parameter to true, forces synchronous sourcing.

This sample shows using the forceSyncSourcing parameter in the setCurrentSublistValue method. The forceSyncSourcing parameter is also available in the setText, setValue, setCurrentSublistText, setMatrixHeaderValue, and setCurrentMatrixSublistValue methods.

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/currentRecord'], function(currentRecord){
    var rec = currentRecord.get();
    rec.selectNewLine({
        sublistId: 'item'
    });
    rec.setCurrentSublistValue({
        sublistId: 'item',
        fieldId: 'item',
        value: 39,
        forceSyncSourcing:true
    });
    rec.setCurrentSublistValue({
        sublistId: 'item',
        fieldId: 'quantity',
        value: 1,
        forceSyncSourcing:true
    });
    rec.commitLine({sublistId: 'item'});
}) 

        

General Notices