2017-08-15 77 views
1

我想要在netsuite中執行bin itemfulfillmentitemfulfillment:子列表項目字段inventorydetail不是子記錄字段

但我無法得到一個有效的例子。當我運行下面的代碼,我收到此錯誤:

Sublist item field inventorydetail is not a subrecord field

我需要知道什麼是正確的子記錄的名稱創建一個itemfulfillment

謝謝!

var sales_internalid = '2465'; //saleorderid 
    var einternalid = '110'; //employeeid 
    var winternalid = '1'; //washsoueid 
    var sinternalid = '6'; //itemid 
    var quantity = 1; 
    var displayname ='iphone'; 
    var shipgroup = 1; 
    var salesOrder= nlapiCreateRecord('salesorder', sales_internalid, {recordmode: 'dynamic'}); 

    var obj = nlapiTransformRecord('salesorder', sales_internalid, 'itemfulfillment'); 
    obj.selectLineItem('item',1); 
    obj.setCurrentLineItemValue('item', 'item', sinternalid); 
    obj.setCurrentLineItemValue('item', 'location', winternalid); 
    obj.setCurrentLineItemValue('item', 'quantity', 1); 
    var subrecord= obj.editCurrentLineItemSubrecord('item', 'inventorydetail'); 
    subrecord.selectLineItem('inventoryassignment', 1); 
    subrecord.selectNewLineItem('inventoryassignment'); 
    subrecord.setCurrentLineItemValue('inventoryassignment', 'inventorynumber', '1'); 
    subrecord.setCurrentLineItemValue('inventoryassignment', 'quantity', '1'); 
    subrecord.commitLineItem('inventoryassignment'); 
    subrecord.commit(); 
    obj.commitLineItem('item'); 

    var fulfillmentOrderId = nlapiSubmitRecord(itemFulfillment, true); 
+0

評論語法 – Fabien

回答

1

我在通過客戶端代碼進行第一次庫存轉儲時遇到了同樣的問題。當啓用了「高級紙盒管理」功能時,發現「紙盒編號」字段僅爲次要記錄。如果您正在使用的帳戶設置爲「使用分類」,則交易行項目上的「分類號」字段將通過其文本值進行設置。例子在SS 2.0中,但我相信它可以得到:

  newRec = nsRecord.create({ 
       type: nsRecord.Type.INVENTORY_ADJUSTMENT, 
       isDynamic: true 
      }); 

      // In dynamic mode must set the subsidiary first. 
      newRec.setValue({ 
       fieldId: bodyFields.subsidiary, 
       value: locSub[datain.Location] 
      }); 
      newRec.setValue({ 
       fieldId: bodyFields.adjustment_Location, 
       value: datain.Location 
      }); 
      newRec.setValue({ 
       fieldId: bodyFields.date, 
       value: date 
      }); 
      newRec.selectNewLine({ 
       sublistId: columnFields.type 
      }); 
      newRec.setCurrentSublistValue({ 
       sublistId: columnFields.type, 
       fieldId: columnFields.item, 
       value: datain.Item 
      }); 
      newRec.setCurrentSublistValue({ 
       sublistId: columnFields.type, 
       fieldId: columnFields.adjust_Qty, 
       value: datain.Quantity.toString() 
      }); 
      if (parseFloat(datain.Quantity) > 0) { // If qty is positive must set the Est Unit Cost. 
       itemVals = nsSearch.lookupFields({ 
        type: nsSearch.Type.ITEM, 
        id: datain.Item, 
        columns: fields 
       }); 
       cost = itemVals.averagecost || itemVals.lastpurchaseprice; 
       newRec.setCurrentSublistValue({ 
        sublistId: columnFields.type, 
        fieldId: columnFields.est_Unit_Cost, 
        value: cost 
       }); 
      } 
      // 
      // Format for binnumbers field is 'ValueText(qty)\rValueText(qty)\rValueText(qty) 
      // the only exception is in cases of negative qty 
      // 
      binText = datain.Bin ? datain.Bin + '(' + datain.Quantity + ')' : ''; 
      newRec.setCurrentSublistValue({ 
       sublistId: columnFields.type, 
       fieldId: columnFields.bin_Numbers, 
       value: binText 
      }); 
      newRec.commitLine({ 
       sublistId: columnFields.type 
      }); 
      invRecResult.invRecId = newRec.save({ 
       enableSourcing: true, 
       ignoreMandatoryFields: true 
      });