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

使用NetSuite SuiteTalk PHPToolKit创建供应商付款记录报错求助

解决NetSuite SuiteTalk创建Vendor Payment时的"Adding new line to sublist apply is not allowed"错误

这个错误的核心原因是:创建供应商付款(Vendor Payment)关联账单时,apply子列表不能直接通过账单编号(refNum)新增关联行,必须通过账单的**内部ID(internalId)**关联,同时需正确配置applyList的replaceAll属性。

修改后的代码示例

$vendorPayment                     = new VendorPayment();
$vendorPayment->entity             = new RecordRef();
$vendorPayment->entity->internalId = $bill->entity->internalId;
$vendorPayment->entity->type       = 'vendor';
$vendorPayment->account            = new RecordRef();
$vendorPayment->account->internalId = self::SB_ACCOUNT_INTERNAL_ID;
$vendorPayment->apAcct             = new RecordRef();
$vendorPayment->apAcct->internalId = $bill->account->internalId;
// 推荐用customForm的internalId而非name,避免名称重复问题
$vendorPayment->customForm             = new RecordRef();
$vendorPayment->customForm->internalId = $bill->customForm->internalId;
$vendorPayment->subsidiary             = new RecordRef();
$vendorPayment->subsidiary->internalId = $bill->subsidiary->internalId;
// 将time()改为标准日期格式,NetSuite接受YYYY-MM-DD或ISO格式
$vendorPayment->tranDate = date('Y-m-d');
$vendorPayment->memo     = 'Testing Memo';

// 创建关联账单的行项,关键是使用账单的internalId
$lineItem = new \NetSuite\Classes\VendorPaymentApply();
$lineItem->apply = true;
$lineItem->type = 'Bill';
$lineItem->internalId = $bill->internalId; // 替换refNum为账单的内部ID
$lineItem->amount = 30.00;        

// 配置applyList,必须设置replaceAll为true
$vendorPayment->applyList = new \NetSuite\Classes\VendorPaymentApplyList();
$vendorPayment->applyList->apply = [$lineItem];
$vendorPayment->applyList->replaceAll = true; // 新增此属性,告知NetSuite替换现有关联行

关键修改点说明

  • 关联账单用internalId而非refNum:NetSuite的apply子列表需要通过账单的唯一内部ID来关联,而非账单编号(tranId/refNum),后者可能存在重复或无法精准匹配的问题。
  • 设置applyList.replaceAll = true:这个属性告知NetSuite用当前传入的apply行项替换默认的关联列表,避免"不允许新增行"的错误。
  • 修复tranDate格式:time()返回的时间戳不符合NetSuite的日期格式要求,改用date('Y-m-d')生成标准日期字符串。
  • customForm改用internalId:使用表单的内部ID比名称更可靠,避免因表单名称重复导致的匹配失败。

内容的提问来源于stack exchange,提问作者Ranva Rahul

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 23:03:22