我正在使用用户事件脚本在工作单上构建一个按钮,该脚本将使用工作单和子列表中的一些信息创建库存调整。按钮是使用用户事件脚本创建的,并调用客户端脚本。
我做了一些测试,当在客户端脚本中使用非批次编号的项目保存库存调整时,它可以工作,并且不会给我一个错误。当我尝试输入批次编号项目的库存详细信息时,我发现event.record.getCurrentSublistField不是一个函数。这个错误不是发生在我的脚本上,而是似乎发生在系统脚本上。我在这里添加我的客户端脚本。你知道为什么会发生这种事吗?
定义(‘N/record’,'N/search','N/currentRecord','N/runtime',
函数(记录、搜索、currentRecord、运行时){
function pageInit(context) {
}
function buildSecondaryItems(){
var currentWo = currentRecord.get();
var currentId = currentWo.id;
var account = runtime.getCurrentScript().getParameter('custscript_cab_accountparamater');
console.log(currentId);
console.log(account);
var workOrder = record.load({
type: "workorder",
id: currentId
});
var location = workOrder.getValue({
fieldId: 'location'
})
var batch = workOrder.getValue({
fieldId: 'custbody_cab_processingbatchfield'
})
var batchName = workOrder.getText({
fieldId: 'custbody_cab_processingbatchfield'
})
var assembly = workOrder.getValue({
fieldId: 'assemblyitem'
})
var subsidiary = workOrder.getValue({
fieldId: 'subsidiary'
})
console.log("Location: "+location);
console.log("Batch: "+batch);
console.log("Batch Name: "+batchName);
console.log("Assembly: "+ assembly);
console.log("Subsidiary: "+ subsidiary);
// Getting information from the related Assembly build on the Work order
var assemblyBuildSearch = search.load({id: 'customsearch274'})
var firstResult = runRelatedRecordSearch(assemblyBuildSearch,currentId)
var glImpact = firstResult.getValue(assemblyBuildSearch.columns[1]);
var qtyBuilt = firstResult.getValue(assemblyBuildSearch.columns[2]);
var date = firstResult.getValue(assemblyBuildSearch.columns[3]);
console.log("gl Impact: " + glImpact);
console.log("qty Built: " + qtyBuilt);
console.log("date: " + date);
// Creating the Inventory Adjustment
var inventoryAdjustment = record.create({
type: "inventoryadjustment",
isDynamic: true,
defaultValues :null
});
// Setting Main value on Inventory Adjustment
inventoryAdjustment.setValue({
fieldId: 'subsidiary',
value: subsidiary
});
inventoryAdjustment.setValue({
fieldId: 'trandate',
value: new Date(date)
});
inventoryAdjustment.setValue({
fieldId: 'account',
value: account
});
inventoryAdjustment.setValue({
fieldId: 'adjlocation',
value: location
});
inventoryAdjustment.setValue({
fieldId :'custbody_cab_processingbatchfield',
value: batch
});
inventoryAdjustment.setValue({
fieldId :'custbody_cab_adjustmenttype',
value: '2'
});
inventoryAdjustment.setValue({
fieldId :'custbody_cab_invadjworkorder',
value: currentId
});
//Entering the first line on the inventory Adjustment
inventoryAdjustment.selectNewLine({
sublistId: 'inventory'
});
inventoryAdjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'item',
value: assembly
});
inventoryAdjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'location',
value: location
});
inventoryAdjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'adjustqtyby',
value: qtyBuilt
});
inventoryAdjustment.setCurrentSublistValue({
sublistId: 'inventory',
fieldId: 'unitcost',
value: glImpact/qtyBuilt
});
//Selecting the inventory detail subrecord and setting the values.
var subrecord = inventoryAdjustment.getCurrentSublistSubrecord({
sublistId: 'inventory',
fieldId: 'inventorydetail'
});
subrecord.selectNewLine({
sublistId: 'inventoryassignment'
});
subrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
value: "ALT1"
});
subrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'inventorystatus',
value: '1'
});
subrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: qtyBuilt
});
// Committing the inventory detail and first line
subrecord.commitLine({
sublistId: 'inventoryassignment'
});
inventoryAdjustment.commitLine({
sublistId: 'inventory'
});
var inventoryAdjustmentID = inventoryAdjustment.save({
enableSourcing: true,
ignoreMandatoryFields: false
});
}
function runRelatedRecordSearch(assemblyBuildSearch,currentId){
var filter = search.createFilter({ // Creates filter on created from field
name:'createdfrom',
operator: search.Operator.IS,
values: currentId
})
assemblyBuildSearch.filters.push(filter);
var results = assemblyBuildSearch.run();
var firstResult = results.getRange({
start: 0,
end: 1
})[0];
return firstResult;
}
return {
pageInit: pageInit,
buildSecondaryItems: buildSecondaryItems
};});
提前谢谢你
发布于 2020-07-02 22:48:05
我联系了Netsuite支持人员,这个问题是由"issueinventorynumber“fieldId引起的。尽管这是记录浏览器上的字段,但支持代表确认这是一个错误,并开放了一个增强功能来更改它。我需要使用"receiptinventorynumber“才能正常工作。
发布于 2020-06-23 23:25:02
Abed,我不能评论太多,因为我不熟悉(我从来没有尝试过以这种方式编写脚本),但是由UE调用的客户端脚本应该是模块化的,并且几乎从未部署过。-因此,通过设计,您对'custscript_cab_accountparamater‘的调用必然会失败。
调用CS的UE可以通过类似的(修改的)过程将参数传递给CS,这就是如何使用参数调用CS。也许这就是你应该做的。
但在我看来,首先您需要更改类似于库的客户端脚本的结构-然后您可以通过按钮访问函数,从而进行进一步的测试。
https://stackoverflow.com/questions/62430299
复制相似问题