将VendorCreditApply添加到VendorCreditApplyList Suitetalk

本文关键字:VendorCreditApplyList Suitetalk 添加 VendorCreditApply | 更新日期: 2023-09-27 18:22:06

我不知道为什么在尝试用VendorCreditApplyList 更新VendorCredit时会出现此错误

var creditObj = new List<VendorCredit>(searchResultCredit.recordList.Cast<VendorCredit>()).FirstOrDefault();
VendorCreditApplyList vCreditApplyList = new VendorCreditApplyList();
VendorCreditApply[] vCreditApplyArray = new VendorCreditApply[creditObj.applyList.apply.Length + 1];
var searchResultBill = _service.search(transactionsSearchBill);
if (searchResultCredit.status.isSuccess)
{
   var billObj = new List<VendorBill>(searchResultBill.recordList.Cast<VendorBill>()).FirstOrDefault();
   for(int i = 0; i < creditObj.applyList.apply.Length; i ++)
   {
      vCreditApplyArray[i] = creditObj.applyList.apply[i];
   }
   vCreditApplyArray[creditObj.applyList.apply.Length] = new VendorCreditApply()
      {
         amount = (double)creditAmount,
         amountSpecified = true,
         apply = true,
         applySpecified = true,
         applyDate = DateTime.Now,
         applyDateSpecified = true,
         currency = billObj.currencyName,
         doc = Convert.ToInt64(billObj.internalId),
         docSpecified = true,
         due = billObj.userTotal,
         dueSpecified = true,
         line = 0,
         lineSpecified = true,
         refNum = null,
         total = billObj.userTotal,
         totalSpecified = true,
         type = "Bill"
      };
}
vCreditApplyList.apply = vCreditApplyArray;
creditObj.applyList = vCreditApplyList;              
WriteResponse writeRes = _service.update(creditObj);
return writeRes.status;

我得到错误:

"请求全部替换时,必须指定子列表applyList的所有行"

我真的不明白。。。

将VendorCreditApply添加到VendorCreditApplyList Suitetalk

您正在将creditObj.applyList属性设置为vCreditApplyList。这是一个空列表,因为在声明它之后你不会对它做任何事情。你已经通过复制子列表和添加新元素创建了vCreditApplyArray,但你还没有用它更新vCreditApplyList

我找到了答案。

因为VendorCredit是一个Keyed Sublist,所以我只需要添加replaceAll=false,然后只提交我必须添加的记录。

相关文章:
  • 没有找到相关文章