我无法保存供应商帐单,因为它将出现一个错误,当我不输入库存帐单时,需要输入库存明细。但是,当我尝试为库存相关字段输入任何值时,将出现错误“您无法为该项目创建库存明细”。可用的项目字段如下(从调试器复制):
amount = {string}
amounthasbeenset = {string}
billreceipts = {string}
billvariancestatus = {string}
billvariancestatusallbook = {string}
binitem = {string}
class = {string}
customer = {string}
ddistrib = {string}
department = {string}
description = {string}
fulfillable = {string}
fulfillmentstatus = {string}
generateaccruals = {string}
groupsetup = {string}
hasimmutableamortization = {string}
id = {string}
inboundshipmentitem = {string}
includegroupwrapper = {string}
ingroup = {string}
initoqpbucket = {string}
initquantity = {string}
inventorydetailavail = {string}
inventorydetailreq = {string}
isbillable = {string}
islinefulfilled = {string}
islinkedtodropshippoline = {string}
isnoninventory = {string}
isnumbered = {string}
isserial = {string}
item = {string}
itemhandlingcost = {string}
itemresidamt = {string}
itemresidamtispct = {string}
itemshippingcost = {string}
itemsubtype = {string}
itemtype = {string}
landedcostcategory = {string}
landedcostset = {string}
linenumber = {string}
location = {string}
locationusebins = {string}
locationusesbins = {string}
mandatorylocation = {string}
marginal = {string}
matrixtype = {string}
olditemid = {string}
options = {string}
oqpbucket = {string}
orderdoc = {string}
orderline = {string}
origlocation = {string}
origrate = {string}
printitems = {string}
quantity = {string}
rate = {string}
rateschedule = {string}
scheduletype = {string}
tracklandedcost = {string}
vendorname = {string}
weightinlb = {string}
我正在设置以下库存明细值(除了项目,数量和位置之外)。没有库存分配子列表。
inventorydetailavail = F
inventorydetailreq = F
binitem = F
isserial = F
isnumbered = F
locationusesbins = F
locationusebins = F
itemtype = NonInvtPart
isnoninventory = T
这是我使用的代码示例:
define(['N/record','N/redirect','N/search'],
function(record, redirect, search) {
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request - Encapsulation of the incoming request
* @param {ServerResponse} context.response - Encapsulation of the Suitelet response
* @Since 2015.2
*/
function onRequest(context) {
var request = context.request;
var response = context.response;
var id = context.request.parameters.custom_id;
if (!id) {
context.response.write('The parameter "custom_id" is required');
return;
}
else {
alert('ID is ' + id);
}
var loadedRecord = record.load({
type: record.Type.INBOUND_SHIPMENT,
id: id
});
alert('Generating vendor bill');
var shipmentBaseCurrency = loadedRecord.getValue('shipmentbasecurrency');
var vendorBill = record.create({
type: record.Type.VENDOR_BILL,
isDynamic: true
});
vendorBill.setValue('currency', shipmentBaseCurrency);
var receivingLocation = '';
var lines = loadedRecord.getLineCount({sublistId: 'items'});
log.debug("tran. lines: " + lines);
var total;
for (var i = 0; i < lines; i++) {
var quantity = (parseFloat(loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "quantityreceived",
line: i
})) || 0);
var purchaseOrder = loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "purchaseorder",
line: i
});
var item = loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "itemid",
line: i
});
var description = loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "shipmentitemdescription",
line: i
});
var recLoc = loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "receivinglocation",
line: i
});
receivingLocation = recLoc;
var totalUnitCost = loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "totalunitcost",
line: i
});
var amount = loadedRecord.getSublistValue({
sublistId: "items",
fieldId: "shipmentitemamount",
line: i
});
log.debug("item quantity: " + quantity);
vendorBill = addVendorBillLine(vendorBill, item, quantity, receivingLocation);
} // for (var i = 0; i < lines; i++)
var vbPostPeriodValStr = String(getPostingPeriod());
try {
vendorBill.setText('postingperiod', vbPostPeriodValStr);
}
catch(e) {
log.error('Issue setting posting period for vendor bill', e.message);
}
vendorBill.setValue('location', receivingLocation);
try {
var vendorBillId = vendorBill.save();
log.debug('*******Vendor Bill Saved*******', 'Vendor bill successfully saved: ' + vendorBillId);
redirect.toRecord({
type: record.Type.VENDOR_BILL,
id: vendorBillId
});
}
catch(e) {
log.debug('Error saving vendor bill', e.message);
context.response.write('Error: ' + e.message);
}
}
function addVendorBillLine(vendorBill, item, quantity, location) {
try {
var lineNum = vendorBill.selectNewLine({
sublistId: 'item'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "item",
value: item
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "quantity",
value: quantity
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "location",
value: location
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "itemtype",
value: 'NonInvtPart'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "isnoninventory",
value: 'T'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "inventorydetailreq",
value: 'F'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "inventorydetailavail",
value: 'F'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "binitem",
value: 'F'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "locationusebins",
value: 'F'
});
vendorBill.setCurrentSublistValue({
sublistId: "item",
fieldId: "vendorname",
value: 'Test Vendor'
});
vendorBill.commitLine({sublistId:"item"});
log.debug('Committing vendor bill expense line addition','Name: ' + item + ", Quantity: " + quantity);
}
catch(e){
log.debug('Issue committing vendor bill item line addition', e.message);
}
return vendorBill;
}
function getPostingPeriod() {
var monthAbbr = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
var d = new Date();
return monthAbbr[d.getMonth()] + ' ' + d.getFullYear();
}
return {
onRequest: onRequest
};
});
答案 0 :(得分:1)
在SuiteScript中创建 itemfulfillment 时,我也遇到了很多问题。我还没有尝试过创建供应商清单,但是由于您需要设置库存详细信息,因此应遵循相同的规则。在创建ItemFulfillments时,这就是我发现的
from selenium.webdriver.support.wait import WebDriverWait
并不总是返回有效值,即即使子列表项不具有清单明细的子记录(无序列,批次或仓位),它也返回true,因此您需要搜索并验证当前值该项目需要库存详细信息,即已启用序列,批次或箱位。hasSublistSubrecord/hasSubrecord
,因此仅在创建带有库存明细的记录时才必须使用 nonDynamic 模式。dynamicMode = true
不会引发错误,这意味着对没有序列号,批次或仓位的行项目使用getSubRecord\getSublistSubrecord
会返回子记录,但是如果您在其中设置了库存明细,则NetSuite将抛出错误您无法为此项目创建库存明细。