NetSuite 交易中有很多日期可供选择,特别是销售订单。我正在使用 SuiteTalk 将运输信息从 NetSuite 同步到旧系统。哪个日期是确定针对销售订单发生活动以指示已发货的正确日期?
3 回答
在查看和比较所有销售订单中的所有日期值之后,我得出的结论是,没有明确的赢家可以显示它最后一次活动的日期/时间。公式字段是最好的解决方案。这是一个演示该公式的已保存搜索。
请注意下面的公式,它从所有相关日期中找到最大日期。
此计算日期还可用于筛选器,以仅查找最近修改的销售订单项目,特别是那些与跟踪号和数量一起发货的项目。
这是可以剪切和粘贴格式的公式。
GREATEST({trandate},{lastmodifieddate},{linelastmodifieddate},{billingtransaction.trandate},{billingtransaction.lastmodifieddate},{billingtransaction.linelastmodifieddate})
联系 NetSuite 支持后,我了解到 {linelastmodifieddate} 无法通过 SuiteTalk API 获得。这给我留下了以下日期:
{trandate}
{lastmodifieddate}
{billingtransaction.trandate}
{billingtransaction.lastmodifieddate}
就我而言,我正在监视所有销售订单以查看何时发货。所以我想知道我们什么时候在内部完成一个订单项,或者我们什么时候直接发货。我遇到的问题是这些日期到处都是。我想包括 {linelastmodifieddate},因为有时它是最近的。
由于我们在商品发货或直接发货时开具发票,因此 {billingtransaction.trandate} 代表准确的发货日期。{billingtransaction.quantity} 代表准确的发货数量。{billingtransaction.trackingnumbers} 包含该货件的跟踪编号列表。这就是我查看销售订单中每个行项目的“发货状态”所需的全部信息。
这是我开始使用的一些示例代码,用于识别最近发货的销售订单。
service.searchPreferences = new SearchPreferences();
service.searchPreferences.bodyFieldsOnly = false;
service.searchPreferences.returnSearchColumns = true;
TransactionSearchAdvanced customSearch = new TransactionSearchAdvanced()
{
savedSearchScriptId = "customsearch_[your saved search here]"
,criteria = new TransactionSearch()
{
[your criteria here]
}
};
Console.WriteLine("Querying NetSuite");
SearchResult res = service.search(customSearch);
Console.WriteLine("\nThe search() operation completed successfully.");
Console.WriteLine(" Total Records = " + res.totalRecords);
Console.WriteLine(" Total Pages = " + res.totalPages);
Console.WriteLine(" Page Size = " + res.pageSize);
Console.WriteLine(" Current Page Index = " + res.pageIndex);
List<TransactionSearchRow> tsRows = new List<TransactionSearchRow>();
// Page through all the results
while (res.searchRowList.Length > 0)
{
foreach (TransactionSearchRow transactionRow in res.searchRowList)
{
tsRows.Add(transactionRow);
}
Console.WriteLine("\nQuerying NetSuite again...");
res = service.searchMore(++res.pageIndex);
}
// Sort the results
tsRows.Sort(delegate (TransactionSearchRow x, TransactionSearchRow y)
{
return x.basic.tranId[0].searchValue.CompareTo(y.basic.tranId[0].searchValue);
});
int i = 1;
// Parse the results
foreach (TransactionSearchRow tsRow in tsRows)
{
TransactionSearchRowBasic transactionRowBasic = tsRow.basic;
ItemSearchRowBasic itemRowBasic = tsRow.itemJoin;
TransactionSearchRowBasic billingRowBasic = tsRow.billingTransactionJoin;
string itemItemId = "";
string itemDesc = "";
double reqQty = 0;
string billTranId = "";
double billQty = 0;
string billTrackNo = "";
try { itemItemId = itemRowBasic.itemId[0].searchValue; } catch { }
try { itemDesc = itemRowBasic.salesDescription[0].searchValue; } catch { }
try { reqQty = transactionRowBasic.quantity[0].searchValue; } catch { }
try { billTranId = billingRowBasic.tranId[0].searchValue; } catch { }
try { billQty = billingRowBasic.quantity[0].searchValue; } catch { }
try { billTrackNo = billingRowBasic.trackingNumbers[0].searchValue; } catch { }
DateTime trandate = DateTime.MinValue;
DateTime lastmodifieddate = DateTime.MinValue;
DateTime billtrandate = DateTime.MinValue;
DateTime billlastmodifieddate = DateTime.MinValue;
try { trandate = transactionRowBasic.tranDate[0].searchValue; } catch { }
try { lastmodifieddate = transactionRowBasic.lastModifiedDate[0].searchValue; } catch { }
try { billtrandate = billingRowBasic.tranDate[0].searchValue; } catch { }
try { billlastmodifieddate = billingRowBasic.lastModifiedDate[0].searchValue; } catch { }
var list = new List<DateTime>();
list.Add(Convert.ToDateTime(trandate));
list.Add(Convert.ToDateTime(lastmodifieddate));
list.Add(Convert.ToDateTime(billtrandate));
list.Add(Convert.ToDateTime(billlastmodifieddate));
DateTime maxdate = list.Max(date => date);
Console.WriteLine(
$"\n {i++} of {tsRows.Count}" +
$"\n Document Number: {transactionRowBasic.tranId[0].searchValue}" +
$"\n SO Date: {trandate}" +
$"\n SO Modified: {lastmodifieddate}" +
$"\n Invoice Date: {billtrandate}" +
$"\n Invoice Modified: {billlastmodifieddate}" +
$"\n +++Max Date: {maxdate}" +
$"\n Item Name: {itemItemId}" +
$"\n Item Description: {itemDesc}" +
$"\n Bill Doc Number: {billTranId}" +
$"\n Requested Qty: {reqQty}" +
$"\n Bill Qty: {billQty}" +
$"\n Tracking Nos: {billTrackNo}"
);
}
service.logout();
Console.WriteLine("\n\nHit Enter to close this window.");
Console.ReadLine();