2017-10-06 70 views
0

我目前在程序集構建中對客戶端腳本的庫存詳細信息子記錄有些問題。如您所知,Assembly Builds有兩個庫存詳細信息。右上角的按預期工作,我可以使用Suitescript訪問每個字段。庫存分配子列表不會對套件做出反應

雖然我在底部庫存明細方面遇到了問題。我能夠訪問它並使用nlapiGetFieldValue()就好了。但是,當我訪問子列表時,我只能查找'id'的值。

這些是應該存在的字段,還有一個名爲「receipttinventorynumber」的記錄較少的字段。

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' ,和'內部'工作。 'receipttinventorynumber'沒有。其他領域也沒有。

由於我的用例,我不能等待記錄保存在服務器上。我必須趕上這個客戶端。任何建議表示讚賞。

回答

1

剛剛能回答我自己的問題,但它確實最終涉及服務器端搜索。我很確定它是按照我的意願工作的,但我仍然參與測試。實質上,我抓住了領域'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); 
1

我已經使用Inventory Detail subrecord已經很長時間了,但我認爲還有另一個字段叫'assigninventorynumber'。你嘗試過使用它嗎?

+0

那麼,我沒有嘗試過。我現在只是測試它。不幸的是,它也沒有奏效。在好的方面,我只測試了其他幾個人......他們可能會工作。我肯定會回覆你的=)。 –

相關問題