``` function yieldScript() { var state = nla...
# general
s
Copy code
function yieldScript() {
      var state = nlapiYieldScript();
      if (state.status == 'FAILURE') {
          nlapiLogExecution('ERROR', "Failed to yield script, exiting: Reason = " + state.reason + " / Size = " + state.size);

          if (state.reason == 'SS_DISALLOWED_OBJECT_REFERENCE') {
              nlapiLogExecution('ERROR', "Disallowed object type: " + state.information);
          }
          throw "Failed to yield script";
      } else if (state.status == 'RESUME') {
          nlapiLogExecution('AUDIT', "Resuming script because of " + state.reason + ".  Size = " + state.size);
      }
      state = null;
  }

function run() {

    nlapiLogExecution('DEBUG', 'before yield 1');
  
    yieldScript();
    
    var salesOrderRecord = nlapiLoadRecord('salesorder', 1731827)

    nlapiLogExecution('DEBUG', 'before yield 2');

    yieldScript();

    nlapiLogExecution('DEBUG', 'done');
}