7

我启用了多地点功能和多地点库存。我需要一种方法来设置或检索特定于位置的值,例如现有位置、位置下一个计数日期、位置最后计数日期、位置库存计数间隔。

这些字段可通过 Saved Search 界面访问,但 SuiteAnswers 上没有关于如何通过 SuiteScript API 获取它们的文档。SuiteScript Records 浏览器没有用于访问此子列表的条目。如何在不使用搜索的情况下使用 SuiteScript API 设置或检索值?

具体来说,我希望能够加载记录,为特定位置设置下一个库存盘点日期,然后提交并关闭并实际查看 Netsuite 中的更改。目前我发现的唯一解决方法是笨拙地在套件脚本中构建一个 CSV 文件并将其提交给作业管理器,但这有其自身的局限性。

4

2 回答 2

11

子列表名称未记录且不受官方支持,但您仍然可以使用子列表 ID“locations”,IE 访问它

//load arbitrary item record
var itemRec = nlapiLoadRecord('inventoryitem', 655009)

//find the line with location internal ID 1
var line = itemRec.findLineItemValue('locations','location',1);
//get that line's location count interval
var countinterval = itemRec.getLineItemValue('locations', 'invtcountinterval', line);

//calculate the next count date as today + interval, set up the
//last count date as a string
var lastCountDate = nlapiDateToString(new Date());
var nextCountDate = new Date() + countInterval*MILLISECONDS_IN_DAY;
nextCountDate = nlapiDateToString(nextCountDate);

//set the values on the item
itemRec.setLineItemValue('locations','lastinvtcountdate', line, lastCountDate);
itemRec.setLineItemvalue('locations','nextinvtcountdate', line, nextCountDate);

nlapiSubmitRecord(itemRec);

您可以通过在子列表界面上使用 chrome 中的“检查元素”之类的内容来发现子列表的字段名称。例如,右键单击任何项​​目的位置子列表上的“下一个库存盘点日期”标题,然后单击“检查元素”。查看出现的 div.listheader,在其上方,您会看到类似

.elements['locationssortfld'].value='nextinvtcountdate'

'nextinvtcountdate' 将是您插入到 nlapiSetLineItemValue 的字段参数中的字段 ID。

希望对某人有所帮助。我第一次自己解决了这个问题,虽然现在看起来更明显了。

于 2016-01-21T23:24:08.393 回答
0

您还可以使用这些字段 ID 从搜索中访问您想要的字段。

new nlobjSearchColumn("locationquantityavailable",null,null) 
new nlobjSearchColumn("locationquantityonhand",null,null) 
new nlobjSearchColumn("locationlastinvtcountdate",null,null, 
new nlobjSearchColumn("locationnextinvtcountdate",null,null) 
new nlobjSearchColumn("locationinvtcountinterval",null,null)
于 2017-09-19T20:15:59.370 回答