仅使用项目的外部id在Netsuite中使用Suitescript创建发票

仅使用项目的外部id在Netsuite中使用Suitescript创建发票,netsuite,suitescript,Netsuite,Suitescript,是否可以使用项目的外部id而不是使用Restlet的内部id创建发票?我可以在邮递员身上做到这一点: “项目”:{ “项目”:[ { “金额”:120.0, “项目”:{ “外部化”:“12878” }, “税收代码”:{ “id”:“13” } } ] } 但是当我试图在Restlet中设置相同的值时,它抛出了一个错误 var currentItem=项目[i]; 记录。选择NewLineItem('item'); record.setCurrentLineItemValue('item

是否可以使用项目的外部id而不是使用Restlet的内部id创建发票?我可以在邮递员身上做到这一点:

“项目”:{
“项目”:[
{ 
“金额”:120.0,
“项目”:{
“外部化”:“12878”
},
“税收代码”:{
“id”:“13”
}
}
]
} 
但是当我试图在Restlet中设置相同的值时,它抛出了一个错误

var currentItem=项目[i];
记录。选择NewLineItem('item');
record.setCurrentLineItemValue('item','externalid',currentItem[“exId”]);
record.setCurrentLineItemValue('item','quantity',currentItem[“quantity”]);
record.setCurrentLineItemValue('item','rate',currentItem[“rate”]);
record.setCurrentLineItemValue('item','taxcode',currentItem[“taxcode”]);
记录。提交行项目(“项目”);

您需要做的是通过外部id搜索项目

var extIds = items.map(function(it){ return it.exId});
var items = nlapiSearchRecord('item', null, [
    new nlobjSearchFilter('externalid', null, 'anyof', extIds)
], [
    new nlobjSearchColumn('externalid')
]);
// check for null return and throw error
var extIdMap = {};
items.forEach(function(ref){
    extIdMap[ref.getValue('externalid')] = ref.getId();
});

//then instead of record.setCurrentLineItemValue('item', 'externalid', currentItem["exId"]);
record.setCurrentLineItemValue('item', 'item', extIdMap[currentItem["exId"]]);

您需要做的是通过外部id搜索项目

var extIds = items.map(function(it){ return it.exId});
var items = nlapiSearchRecord('item', null, [
    new nlobjSearchFilter('externalid', null, 'anyof', extIds)
], [
    new nlobjSearchColumn('externalid')
]);
// check for null return and throw error
var extIdMap = {};
items.forEach(function(ref){
    extIdMap[ref.getValue('externalid')] = ref.getId();
});

//then instead of record.setCurrentLineItemValue('item', 'externalid', currentItem["exId"]);
record.setCurrentLineItemValue('item', 'item', extIdMap[currentItem["exId"]]);

通常由于未设置项目,[X]的顶级子公司包括子公司。通常由于未设置项目,[X]的顶级子公司包括子公司。谢谢,我目前正在使用项目的外部id进行查找。我想知道为什么restlet有约束,而RESTAPI显然没有约束?谁知道呢。SuiteTalk和SuiteScript数据模型之间一直存在差异。ExternalId也不总是存在于SuiteTalk中;我猜它是由于客户的需求而添加的,以避免为了进行SuiteTalk更新而必须搜索内部id。感谢您的帮助。谢谢您,我目前正在使用该项的外部id进行查找。我想知道为什么restlet会有约束,而REST api显然没有约束?谁知道呢。SuiteTalk和SuiteScript数据模型之间一直存在差异。ExternalId也不总是存在于SuiteTalk中;我猜这是由于客户的需求而添加的,以避免为了更新SuiteTalk而必须搜索内部ID。谢谢您的帮助。