需要帮助添加"包"到项目履行记录,以允许CSR查看哪些项目在哪个跟踪号码下运出。我可以实例化ItemFulfillment记录和ItemFulfillmentPackageList对象,但ItemFulfillmentPackageList对象始终为null - 无法弄清楚如何将ItemFulfillmentPackage对象添加到集合中。我已经尝试了各种方法来分配给ItemFulfillmentPackageList对象而没有运气。创建ItemFulfillmentPakage对象数组是最新的尝试。这是我的代码。
foreach (DataRow dr in dt.Rows)
{
try
{
ItemFulfillment ifRecord = new ItemFulfillment();
ifRecord.packageList = new ItemFulfillmentPackageList();
ifRecord.internalId = dr["Item Fulfillment Internal ID"].ToString();
ItemFulfillmentPackage ifp = new ItemFulfillmentPackage();
ifp.packageDescr = dr["Package Description"].ToString();
ifp.packageTrackingNumber = dr["detail_tracking_information"].ToString();
ItemFulfillmentPackageList ifpl = new ItemFulfillmentPackageList();
Object[] objPackages = new Object[1];
objPackages[1] = ifp;
ifpl = (ItemFulfillmentPackageList)objPackages;
ifRecord.packageList = ifpl;
ifpl.replaceAll = false;
WriteResponse res = _service.update(ifRecord);
if (res.status.isSuccess)
{
;
}
else if (res.status.isSuccessSpecified)
{
;
}
else
displayError(res.status.statusDetail);
}
catch (Exception ex)
{
_logger.error(String.Format("Error in updateItemFulfillment DR method. {0}", ex.Message));
throw new Exception(String.Format("Error in updateItemFulfillment DR method. {0}", ex.Message));
}
}
答案 0 :(得分:0)
确保配置搜索首选项以使bodyFieldsOnly为true;默认情况下,它设置为false,不会加载子列表项。
答案 1 :(得分:0)
我有同样的问题。我最终做的是创建Item Fulfillment事务,包含所有相关的行级别信息,并将其添加到NetSuite。
在此之后,我搜索刚刚添加的项目实现并将跟踪信息添加到记录中。我这样做是通过检查哪个包字段不等于null并将信息添加到该包列表。
在我的情况下,每个订单只使用一个跟踪编号,所有包都包含此编号。您可以根据需要修改此选项以添加跟踪参考。
名为“msg”的变量是包含所有送货信息的货件通知。
我的代码:
TransactionSearch xactionSearch = new TransactionSearch();
TransactionSearchBasic xactionBasic = new TransactionSearchBasic();
xactionBasic.createdFrom = new SearchMultiSelectField();
xactionBasic.createdFrom.@operator = SearchMultiSelectFieldOperator.anyOf;
xactionBasic.createdFrom.operatorSpecified = true;
xactionBasic.createdFrom.searchValue = new RecordRef[1];
xactionBasic.createdFrom.searchValue[0] = new RecordRef { internalId = "SO Internal ID"};
xactionSearch.basic = xactionBasic;
if (useTba = "true".Equals(_custSettings["login.useTba"]))
login();
SearchResult res = _service.search(xactionSearch);
ReadResponse res2 = new ReadResponse();
for (int i = 0; i < res.recordList.Length; i++)
{
if (res.recordList[i] is ItemFulfillment)
{
if (useTba = "true".Equals(_custSettings["login.useTba"]))
login();
res2 = _service.get(new RecordRef { internalId = ((ItemFulfillment)res.recordList[i]).internalId, type = RecordType.itemFulfillment, typeSpecified = true });
}
}
ItemFulfillment item = (ItemFulfillment)res2.record;
ItemFulfillment NewItem = new ItemFulfillment { internalId = item.internalId };
//Fedex
if (item.packageFedExList != null)
{
if (item.packageFedExList.packageFedEx != null)
{
for (int i = 0; i < item.packageFedExList.packageFedEx.Length; i++)
{
item.packageFedExList.packageFedEx[i].packageTrackingNumberFedEx = msg.trackingRef;
}
}
NewItem.packageFedExList = item.packageFedExList;
}
if (item.packageList != null)
{
if (item.packageList.package != null)
{
for (int i = 0; i < item.packageList.package.Length; i++)
{
item.packageList.package[i].packageTrackingNumber = msg.trackingRef;
}
}
NewItem.packageList = item.packageList;
}
//UPS
if (item.packageUpsList != null)
{
if (item.packageUpsList.packageUps != null)
{
for (int i = 0; i < item.packageUpsList.packageUps.Length; i++)
{
item.packageUpsList.packageUps[i].packageTrackingNumberUps = msg.trackingRef;
}
}
NewItem.packageUpsList = item.packageUpsList;
}
//Usps
if (item.packageUspsList != null)
{
if (item.packageUspsList.packageUsps != null)
{
for (int i = 0; i < item.packageUspsList.packageUsps.Length; i++)
{
item.packageUspsList.packageUsps[i].packageTrackingNumberUsps = msg.trackingRef;
}
}
NewItem.packageUspsList = item.packageUspsList;
}
if (useTba = "true".Equals(_custSettings["login.useTba"]))
login();
_service.update(NewItem);