我创建了一个脚本,用于在编辑销售订单时将财务费用项目添加到我的销售订单中,但是无法获取它来设置税码。另外,该行没有提交(因为税码问题?)
我尝试使用内部ID和名称但被卡住了
有帮助吗?
define(['N/currentRecord'],
function(currentRecord) {
function AddFinanceCharge() {
try {
var record = currentRecord.get();
record.selectNewLine({ //add a line to a sublist
sublistId: 'item' //specify which sublist
});
record.setCurrentSublistValue({ //set item field
sublistId: 'item',
fieldId: 'item',
value: 1003 //replace with item internal id
});
record.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'quantity',
value: 1 //replace with quantity
});
record.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'taxCode',
value: 'VAT:S-GB'
});
record.commitLine({ //writes the line entry into the loaded record
sublistId: 'item'
});
log.debug ({
title: 'Success',
details: 'Alert displayed successfully'
});
} catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
return {
pageInit: AddFinanceCharge
};
});
答案 0 :(得分:1)
如果您仅使用税码而不是税组,我相信您可以创建搜索来查找内部ID:
var taxitemSearchObj = search.create({
type: "salestaxitem",
columns: ["internalid", "country", "rate"],
filters: [['firstFilter', 'firstComparisonOperator', firstValue]], 'and', ['anotherFilter', 'anotherComparisonOperator', anotherValue]] // i.e. ['itemid', 'is' 'VAT:S-GB'],
});
您可以在NS记录浏览器中找到可用的搜索过滤器- here (2019.2 version)
“ VAT:S-GB”可能是itemid?然后:
var taxCodeInternalId = taxitemSearchObj.run().getRange(0,1)[0].id // If you know there is only 1 code matching the search query
record.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'taxcode', // FYI I'm not sure if capitalization matters here but I downcased the capital C
value: taxCodeInternalId
});
**免责声明-不适用于混合税代码/税组。为此,您需要使搜索动态化(“ taxgroup”或“ salestaxitem”)。不幸的是,如果在您的税收偏好设置中选择了“在销售和购买中启用税收查找”(设置>会计>税收设置-每个关联设置),Netsuite将覆盖您的税收代码内部ID。如果未选择此选项,则需要确保在每个订单项中设置税码。
答案 1 :(得分:0)
如果您要使用 setValue ,则必须传递税码的内部ID,并使用 SetText 代替setValue并进行检查。