首页 > 解决方案 > 这里的某个地方是一个递归调用,我似乎找不到它。我必须使用 Typescript 和 Lodash 而不是 SuiteScript

问题描述

有人能找到这里发生的递归吗?我很抱歉,我是堆栈溢出的新手,所以如果我的问题描述性不够,请告诉我。

namespace X {
  /**
   * return an instance of the correct record type
   */
  export function getTx(ctx: { currentRecord: record.ClientCurrentRecord }) {
    switch (ctx.currentRecord.type) {
      case record.Type.PURCHASE_ORDER:
        return new PurchaseOrder(ctx.currentRecord)
      case record.Type.TRANSFER_ORDER:
        return new TransferOrder(ctx.currentRecord)
      case record.Type.SALES_ORDER:
        return new SalesOrder(ctx.currentRecord)
      default:
        throw new Error('unknown transaction type')
    }
  }

  export function sublistChanged(ctx: EntryPoints.Client.sublistChangedContext) {
    if (ctx.sublistId === 'item') {
      const rec = X.getTx(ctx)
      rec.custbody_totalitemweightorder = _.sumBy(rec.item, (line: POItemSublist | TOItemSublist | SOItemSublist) => line.quantity * line.custcol_atlas_item_weight!)
    }
  }

标签: typescriptlodashnetsuitesuitescriptsuitescript2.0

解决方案


推荐阅读