首页 文章

库存分配子列表不对Suitescript做出反应

提问于
浏览
0

我目前在程序集构建的库存详细信息子记录的客户端脚本编写方面遇到了一些问题 . 如您所知,Assembly Builds有两个Inventory Details . 右上角的那个按预期工作,我可以使用Suitescript访问每个字段 .

我在底层库存细节方面遇到了麻烦 . 我能够访问它并使用nlapiGetFieldValue()就好了 . 但是,当我访问子列表时,我只能查找'id'的值 .

这些是应该存在的字段,以及一个名为“receiptinventorynumber”的记录较少的字段 .

List of inventory assignment fields

这是我的代码:

//get the line items in the bottom inventory details
var bottom_line_items = [];
for(var line_index = 0; line_index < nlapiGetLineItemCount("component"); line_index++)
{
    var bottom_inv_detail = nlapiViewLineItemSubrecord("component", 'componentinventorydetail', line_index+1);
    if(bottom_inv_detail != null)
    {
        var bottom_line_count = bottom_inv_detail.getLineItemCount('inventoryassignment');
        for(var index =0; index < bottom_line_count; index++)
        {
            bottom_inv_detail.selectLineItem('inventoryassignment', index+1);
            var sn = bottom_inv_detail.getCurrentLineItemValue('inventoryassignment', 'receiptinventorynumber');
            bottom_line_items.push(sn);
        }
    }
}
console.log(bottom_line_items);

以下是在浏览器控制台中执行它的结果:

enter image description here

如您所见,'id'和'internalid'工作 . 'receipttinventorynumber'没有 . 也没有任何其他领域 .

由于我的用例,我不能等待将记录保存在服务器上 . 我必须 grab 这个客户端 . 任何建议表示赞赏 .

2 回答

  • 1

    自从我使用Inventory Detail子记录以来已经很长时间了,但我认为还有另一个名为'assigninventorynumber'的字段 . 你尝试过使用它吗?

  • 1

    只是能够回答我自己的问题,但它最终涉及服务器端搜索 . 我很确定它能像我想要的那样工作,但我仍然参与测试它 . 本质上,我 grab 了'issueinventorynumber'这个有id的字段 . 该ID是“库存序列号”的内部信息,我可以执行搜索以获取实际数量 . 这是结果代码:

    //get the line items in the bottom inventory details
    var bottom_line_ids = [];
    for(var line_index = 0; line_index < nlapiGetLineItemCount("component"); line_index++)
    {
        var bottom_inv_detail = nlapiViewLineItemSubrecord("component", 'componentinventorydetail', line_index+1);
        if(bottom_inv_detail != null)
        {
            var bottom_line_count = bottom_inv_detail.getLineItemCount('inventoryassignment');
            for(var index =0; index < bottom_line_count; index++)
            {
                bottom_inv_detail.selectLineItem('inventoryassignment', index+1);
                var sn = bottom_inv_detail.getCurrentLineItemValue('inventoryassignment', 'issueinventorynumber');
                bottom_line_ids.push(sn);
            }
        }
    }
    
    //do search to identify numbers of bottom serial numbers
    var columns = [new nlobjSearchColumn('inventorynumber')];
    var filters = []
    for(var index = 0; index < bottom_line_ids.length; index++)
    {
        filters.push(['internalid', 'is', bottom_line_ids[index]]);
        filters.push('or');
    }
    //remove the last 'or'
    if(filters.length > 0)
    {
        filters.pop();
    }
    var search = nlapiCreateSearch('inventorynumber', filters, columns);
    var results = search.runSearch().getResults(0,1000);
    bottom_line_items = []
    if(results.length != bottom_line_ids.length)
    {
        //if you get to this point, pop an error as the 'issueinventorynumber' we pulled is associated with multiple serial numbers
        //you can see which ones by doing a 'Inventory Serial Number' Saved Search
        //this is a serious problem, so we'd have to figure out what to do from there
    }
    for(var index = 0; index < results.length; index++)
    {
        bottom_line_items.push(results[index].getValue('inventorynumber'));
    }
    console.log(bottom_line_items);
    

相关问题