0

我尝试使用名为 "Memo Type" 的自定义下拉字段在交易记录上强制使用标准备注字段。如果备忘录类型值为“其他”,则应强制执行标准备忘录。

我在用户事件脚本中处理了此代码,以在通过 CSV 导入导入数据时抛出“自定义错误消息”以显示错误消息。

通过抛出自定义错误消息,脚本可以正常工作,默认情况下,Netsuite 将在下一页抛出服务器端错误消息,要导航表单,应该按下 Go Back。

按下按钮时,页面字段数据被清除并尝试在正文字段级别和子列表级别添加值。

此时,我可以在正文字段级别重新输入值,并且无法在项目子列表上输入行项目

在查看控制台日志时,它仅在 Google Chrome 浏览器上显示错误消息:“Uncaught RangeError: Maximum call stack size exceeded”。

代码:

套件脚本版本:2.0

类型:用户事件,事件:提交前

  function beforeSubmit(scriptContext) {

      log.debug("Value", " Before Submit Initiated");


      var currentTranRecord = scriptContext.newRecord;

      if (currentTranRecord != null && currentTranRecord != '' && currentTranRecord != undefined) {

          var memoNotesValue = "1";
          var isMemoEmpty = false;
          var memoType = currentTranRecord.getValue('custbody_memo_type');

          log.debug('Value', 'MemoNotes : ' + memoType);

          if (memoType != null && memoType != '' && memoType != undefined) {

              if (memoType == memoNotesValue) {

                  var memo = currentTranRecord.getValue('memo');
                  log.debug('Value', 'Memo : ' + memo);

                  if (memo == null || memo == '') {

                      if (scriptContext.type != scriptContext.UserEventType.DELETE) {

                          var errorObj = error.create({
                              code: 'CANNOT SAVE TRANSACTION RECORD',
                              message: 'Please enter the value for the Memo Field'
                          });

                          throw errorObj.code + '\n\n' + errorObj.message;
                          return false;

                      }
                  } else {
                      return true;
                  }

              }

          }


      }
  }

超出最大调用堆栈大小错误

我研究过当存在递归函数时会发生“未捕获的 RangeError:超出最大调用堆栈大小”。但就我而言,我没有使用任何递归函数。但在 Mozilla 浏览器中,相同的代码可以正常工作。

帮助我了解上述错误的原因。提前致谢。

4

0 回答 0