首页 文章

如何在Suitescript中访问/公开Inventory Item Locations子列表字段

提问于
浏览
3

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

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

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

2 回答

  • 5

    子列表名称未记录且未得到官方支持,但您仍可以使用子列表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中的“Inspect Element”之类的内容来发现子列表的字段名称 . 例如,右键单击任何项目的位置子列表上的“下一个库存盘点日期” Headers ,然后单击“检查元素” . 看看出现的div.listheader,就在上面你会看到类似的东西

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

    'nextinvtcountdate'将是您插入nlapiSetLineItemValue的字段参数的字段ID .

    希望能帮助别人 . 我第一次在自己身上花了很多时间来解决这个问题,尽管现在看起来更加明显 .

  • 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)
    

相关问题