You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Suitelet在NetSuite中获取付款记录及付款方部门数据的方案咨询

NetSuite付款单获取部门及成本中心数据的方案

1. 直接查询付款单主记录字段

Bill Payment属于Transaction类型,部门和成本中心(Class)可能是主记录字段,默认查询时可能未包含。用正确的字段ID直接加入查询:

  • 部门字段ID:department
  • 成本中心字段ID:class

示例代码(N/query模块):

const billPaymentQry = query.create({ type: query.Type.TRANSACTION });
const cols = billPaymentQry.columns;
cols.add({ fieldId: 'department' });
cols.add({ fieldId: 'class' });
cols.add({ fieldId: 'tranid' }); // 交易编号
cols.add({ fieldId: 'entity' }); // 实体ID

billPaymentQry.condition = billPaymentQry.createCondition({
    fieldId: 'internalid',
    operator: query.Operator.EQUAL,
    values: [yourPaymentInternalId]
});

const results = billPaymentQry.run().asMappedResults();

2. 关联原始账单获取明细数据

如果部门/成本中心仅在原始Bill的行项目上存在,需通过付款单的apply子列表关联对应Bill:

  1. 读取付款单apply子列表的internalid字段,拿到关联的Bill ID
  2. 查询Bill的TransactionLine记录,提取行项目的部门和成本中心

示例代码:

const paymentRec = record.load({ 
    type: record.Type.BILL_PAYMENT, 
    id: yourPaymentInternalId 
});
const applyLineCount = paymentRec.getLineCount({ sublistId: 'apply' });

for (let i = 0; i < applyLineCount; i++) {
    const billId = paymentRec.getSublistValue({
        sublistId: 'apply',
        fieldId: 'internalid',
        line: i
    });

    // 查询账单行项目
    const billLineQry = query.create({ type: query.Type.TRANSACTION_LINE });
    billLineQry.columns.add({ fieldId: 'department' });
    billLineQry.columns.add({ fieldId: 'class' });
    billLineQry.columns.add({ fieldId: 'amount' });

    billLineQry.condition = billLineQry.createCondition({
        fieldId: 'transaction',
        operator: query.Operator.EQUAL,
        values: [billId]
    });

    const lineResults = billLineQry.run().asMappedResults();
    // 处理行项目数据
}

3. 读取付款单分配子列表

若付款单采用分配规则,部门/成本中心会存储在allocations子列表中:

  • 子列表ID:allocations
  • 字段ID:department、class、amount

示例代码:

const allocationLineCount = paymentRec.getLineCount({ sublistId: 'allocations' });

for (let i = 0; i < allocationLineCount; i++) {
    const deptId = paymentRec.getSublistValue({
        sublistId: 'allocations',
        fieldId: 'department',
        line: i
    });
    const classId = paymentRec.getSublistValue({
        sublistId: 'allocations',
        fieldId: 'class',
        line: i
    });

    // 如需获取名称,加载对应记录
    const deptName = deptId ? record.load({ type: record.Type.DEPARTMENT, id: deptId }).getValue({ fieldId: 'name' }) : '';
    const className = classId ? record.load({ type: record.Type.CLASS, id: classId }).getValue({ fieldId: 'name' }) : '';
}

4. 权限检查

确保Suitelet脚本已配置以下权限:

  • 部门(Department)记录查看权限
  • 分类(Class)记录查看权限
  • 账单(Bill)记录查看权限

内容的提问来源于stack exchange,提问作者qiang xu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 10:24:46