2017-04-20 63 views
0

在我的預定腳本中,我循環遍歷項目實現時已轉換的銷售訂單上的項目,並嘗試設置庫存詳細信息。該庫存明細如下設置沒有任何錯誤或問題,但是當我嘗試保存我得到以下錯誤:無法設置項目實現記錄上的庫存詳細信息 - Suitescript 2

Please configure the inventory detail in line 2 of the item list.

兩線是需要在我的測試庫存明細的唯一項目。下面是代碼:

var itemFulfillment = record.transform({ 
     fromType: record.Type.SALES_ORDER, 
     fromId: salesOrder.fields.id, 
     toType: record.Type.ITEM_FULFILLMENT, 
     isDynamic: true 
    }); 

var lineCount = itemFulfillment.getLineCount({ sublistId: 'item' }); 

for (var i = 0; i < lineCount; i++) { 
      itemFulfillment.selectLine({ 
      sublistId: 'item', 
      line: i 
      }); 

      var remainingQty = itemFulfillment.getCurrentSublistValue({ 
      sublistId: 'item', 
      fieldId: 'quantityremaining' 
      }); 

      itemFulfillment.setCurrentSublistValue({ 
        sublistId: 'item', 
        fieldId: 'quantity', 
        value: remainingQty 
       }); 

      var inventoryDetail = itemFulfillment.getCurrentSublistValue({ 
      sublistId: 'item', 
      fieldId: 'inventorydetailreq' 
      }); 

      var binItem = itemFulfillment.getCurrentSublistValue({ 
      sublistId: 'item', 
      fieldId: 'binitem' 
      }); 

      if (inventoryDetail === 'T' && binItem === 'T') { 

      var inventoryDetailRecord = itemFulfillment.getCurrentSublistSubrecord({ 
       sublistId: 'item', 
       fieldId: 'inventorydetail' 
      });     

      inventoryDetailRecord.selectNewLine({ 
       sublistId: 'inventoryassignment' 
      }); 


      inventoryDetailRecord.setCurrentSublistValue({ 
       sublistId: 'inventoryassignment', 
       fieldId: 'issueinventorynumber', 
       value: 10154 // I know this is the serial number record internal ID for my test 
      }); 

      inventoryDetailRecord.setCurrentSublistValue({ 
       sublistId: 'inventoryassignment', 
       fieldId: 'quantity', 
       value: 1 //Again I know this so hard coded for testing 
      }); 

      inventoryDetailRecord.commitLine({ 
       sublistId: 'inventoryassignment' 
      }); 
      } 
     } 

     var ifRecordId = itemFulfillment.save(); 

提交清單的細節,如果我再檢查inventorydetail子記錄我可以看到,該行有相應的2號線和正確的項目之後。不知道爲什麼當我保存它說第2行需要庫存!

{"type":"inventorydetail","isDynamic":true,"fields":{"itemdescription":"160W PREMIUM GRADE","nlloc":"0","nlsub":"1","trandate":"4/20/2017","_eml_nkey_":"0","type":"inventorydetail","subrecord_parent_tran_type":"ItemShip","nsapiCT":"1492728327986","sys_id":"-19281976277926580","nluser":"-4","nldept":"0","subrecord_transform_from_parent_id":"305887","subrecord_transform_from_parent_tran_type":"SalesOrd","tolocationusesbins":"F","item":"3312","quantity":"1.0","sys_parentid":"19281975969964536","templatestored":"F","entryformquerystring":"orderline=2&unit=&item=3312&quantity=1&subrecord_transform_from_parent_id=305887&trandate=4/20/2017&location=25&uitype=LOH_STRICT_VALIDATION&subrecord_transform_from_parent_tran_type=salesord&subrecord_parent_tran_type=itemship","nlrole":"3","uitype":"LOH_STRICT_VALIDATION","baserecordtype":"inventorydetail","baseunitquantity":"1.0","totalquantity":"1","orderline":"2","haslines":"T","tolocation":"-1","customform":"-10820","location":"25"},"sublists":{"inventoryassignment":{"currentline":{"binnumber":"","binnumber_display":"","existinginventorynumber":"","expirationdate":"","internalid":"-1","inventorydetail":"-1","issueinventorynumber":"","lotquantityavailable":"","quantity":"1","quantityavailable":"","receiptinventorynumber":"","sys_id":"-19281976361182898","sys_parentid":"-19281976277926580","tobinnumber":"","tobinnumber_display":"","#":"2"},"line 1":{"binnumber":"25","binnumber_display":"","existinginventorynumber":"10154","expirationdate":"","internalid":"10154.0","inventorydetail":"-1","issueinventorynumber":"10154","lotquantityavailable":"","quantity":"1.0","quantityavailable":"","receiptinventorynumber":"1793064_3312_NA","sys_id":"-19281976302211623","sys_parentid":"-19281976277926580","tobinnumber":"","tobinnumber_display":""}}}} 

我已經嘗試過所有我能想到的組合,並且遵循套件回答文檔到發球臺。已嘗試在項目詳細信息/作業下的Netsuite記錄瀏覽器中設置每個值,並仍然出現此錯誤。非常感謝幫助/洞察力。

回答

0

它看起來像你正在嘗試做這個客戶端(如與getCurrentSublistSubrecord)

你不能

我要做的就是把必要的信息到自定義字段,然後做這個服務器端或者在用戶事件腳本或預定腳本中。

這樣加上代碼更簡單(類似於你的樣品但是對於元分配):

var invDetail = rec.getSublistSubrecord({ 
    sublistId: targetList, 
    fieldId: 'inventorydetail', 
    line:idx 
}); 
invDetail.setSublistValue({sublistId:'inventoryassignment', fieldId:'binnumber', line:0, value:bintId}); 
invDetail.setSublistValue({sublistId:'inventoryassignment', fieldId:'quantity', line:0, value:getV(qtyField)}); 
+0

對不起,我應該提到這是一個預定腳本。 – Ryan

+0

我已經爲原始問題添加了更多細節。非常感謝您的快速回復:) – Ryan

0

好了,所以bknights沒有得到我的思考。我切換轉化爲標準模式:

 var itemFulfillment = record.transform({ 
      fromType: record.Type.SALES_ORDER, 
      fromId: salesOrder.fields.id, 
      toType: record.Type.ITEM_FULFILLMENT, 
     }); 

刪除isDynamic:真,並在標準模式下的轉換記錄工作。然後,我只需要使用標準的API來更新當前行庫存明細:

 var inventoryDetailRecord = itemFulfillment.getSublistSubrecord({ 
      sublistId: 'item', 
      fieldId: 'inventorydetail', 
      line: i 
     }); 

     inventoryDetailRecord.setSublistValue({ 
      sublistId: 'inventoryassignment', 
      fieldId: 'issueinventorynumber', 
      value: serialId, 
      line: 0 
     }); 

我只需要設置issueinventorynumber這是它,然後保存該項目履行備案。我非常困惑,因爲SuiteScript 2的子列表和子記錄中的文檔顯示這是在動態模式下完成的,並且實際上只顯示如何創建新的庫存編號而不是更新併發佈一個。

1

我是DJ。我在SuiteSuite唱片服務平臺團隊擔任NetSuite的軟件開發人員,我只是在研究這個問題。

履行記錄上的商品子列表就是我們所說的「列表機器」(而不是「編輯機器」)。前者是固定條目列表,您可以在其中編輯值但不添加或刪除線條,而「編輯機器」是您可以添加和刪除線條的列表。在履行記錄中,項目列表是非行可編輯的變體。

inventorydetail子記錄在編輯機的每一行(在項目履行備案),當你操縱的模式,其中isDynamic是假的子記錄只會工作,因爲該項目的機器是一個列表機不兼容動態子記錄。不幸的是,沒有辦法指定子記錄的isDynamic屬性,因爲該屬性當前是從父記錄繼承的。

但是,你可以欺騙它做正確的事情!因此,瑞恩的第二個解決方案。此方法適用於周圍所有的限制如下:

  1. 當轉換銷售訂單到完成備案,省去isDynamic導致履行記錄被作爲DeferredDynamic記錄創建。

  2. 當獲得inventorydetail子記錄,它將從父記錄繼承isDynamic屬性,這意味着它將作爲一個DeferredDynamicSubrecord而非DynamicSubRecord來創建。這使它與項目列表機器兼容,因此該解決方案起作用。

我與產品團隊合作,看看是否有辦法有SuiteScript V2在其環境(或至少,將工作模式),最適合的模式自動創建的每個子記錄。或者,我們可以提供一種方法,在從記錄或從子記錄創建/獲取子記錄時爲其指定參數isDynamic

+0

謝謝@TriskalJM,爲了清理我的文章的格式,現在看起來好多了! – djenning90

+0

樂意幫忙。 :) – TriskalJM

+0

歡迎來到堆棧溢出。如果您在相關主題上添加標籤,您的問題很可能會被可幫助的人注意到。 – Buts

相關問題