javascript - Suitescript 返回所选项目的 vendor 价格

标签 javascript netsuite suitescript

大家晚上好,圣诞快乐!!

我感觉我在向天空撞屁股......

我知道每个项目的 vendor 价格都在每个项目下的子列表中,但我无法弄清楚如何检索所述信息。

我尝试过搜索,但没有成功。

同样,我尝试在项目记录中查找用于搜索“行”的子列表内部 ID,但没有成功。我确实在某处读到过有关“itemvendor”子列表的内容,但 itemRecord.getItemLineCount('itemvendor') 无法识别。

大家有什么想法吗?

干杯

史蒂夫

编辑:我能够使用以下代码实现所需的结果(与@Mike Robbins 代码示例基本相同):

var itemRecord = nlapiLoadRecord('inventoryitem',itemID);
var lines = itemRecord.getLineItemCount('itemvendor');
for (var i=1; i <= lines; i++) {
    var vendor = itemRecord.getLineItemValue ('itemvendor','vendor',i);
    if (vendor == vendorID ) {
        nlapiSetCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_currentprice',itemRecord.getLineItemValue('itemvendor','purchaseprice',i))
        nlapiSetCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_vendorcurrency',itemRecord.getLineItemValue('itemvendor','vendorcurrencyname',i))
        nlapiSetCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_prefer',itemRecord.getLineItemValue('itemvendor','preferredvendor',i))
        i = lines + 1;
    }
}

最佳答案

您也可以在搜索中执行此操作。该字段是 vendor 成本。请注意,如果您仅使用“vendor”而不是“entityid”、“vendor”,您将获得首选 vendor 信息:

nlapiSearchRecord('item', null, [
    new nlobjSearchFilter('vendorcost', null, 'greaterthan', 0),
    new nlobjSearchFilter('itemid', null, 'contains', 'cable')
], [
    new nlobjSearchColumn('itemid'),
    new nlobjSearchColumn('entityid', 'vendor'),
    new nlobjSearchColumn('vendorcost')
]).forEach(function(it) {
    console.log(it.getValue('itemid') + ' ' + it.getValue('entityid', 'vendor') + ' ' + it.getValue('vendorcost'));
});

关于javascript - Suitescript 返回所选项目的 vendor 价格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34433763/

相关文章:

javascript - 如何覆盖交易 View 小部件的研究

javascript - 检查是否已选中每个字段集的一个单选按钮

javascript - 如何在 Javascript 中使用 Q 顺序运行 promise ?

php - 网络套件错误 :You are not requesting the correct data center for your company"

netsuite - SuiteScript 2 Http 请求与回调

javascript - 如何通过在 SuiteScript 2.0 中使用左外连接连接两条记录来在 netsuite 中创建保存的搜索

javascript - Google Places API Web 服务服务器端解决方案

netsuite - 如何使用 SuiteTalk 运行 "Saved Pricing Search"?

javascript - Map/Reduce 脚本中的 getInformation()、Map 和 Reduce 方法有何用途?

Netsuite 内部 URL 内容调用