【问题标题】:How to access/expose Inventory Item Locations sublist fields in Suitescript如何访问/公开 Suitescript 中的库存项目位置子列表字段
【发布时间】:2016-01-21 23:24:08
【问题描述】:

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

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

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

【问题讨论】:

    标签: netsuite suitescript


    【解决方案1】:

    子列表名称未记录且不受官方支持,但您仍然可以使用子列表 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。

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

    【讨论】:

    • 非常酷。通常我从 &xml=T 参数开始,但不会显示位置。
    【解决方案2】:

    您还可以使用这些字段 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多