我目前正在尝试解决一个问题,即我无法从Netsuite中的已保存搜索中获取套件中的值。
"unitprice": 12.6,
"salesdescription": "cheap item",
"custrecord_pm_record_name": {
"internalid": 2,
"name": "test item"
}
基本上我只是想获取上面数组中的值internalid和name。
如果有人知道Netsuite以及如何提取这个值很高的值,或者如果有一种典型的方法可以使用香草JS来获取它也很棒
var _searchId = 'customsearch_pm_item_record_loader';
//itemFilters.push(new nlobjSearchFilter('displayName',null, 'contains', _searchTerm )); //
var rs = nlapiSearchRecord('item', _searchId, itemFilters,columns);
for ( var i = 0; rs != null && i < rs.length; i++)
{
var rowObj = {};
rowObj.id = rs[i].getValue('internalid');
rowObj.custitem_dwr_co_dis = rs[i].getValue('custitem_dwr_co_dis');
rowObj.salesdescription = rs[i].getValue('salesdescription');
rowObj.displayName = rs[i].getValue('displayName');
rowObj.itemid = rs[i].getValue('itemid');
rowObj.unitPrice = rs[i].getValue('unitprice', 'pricing'); // unit price
rowObj.basePrice = rs[i].getValue('baseprice');
rowObj.productImage = rs[i].getText('custitem50');
retObj.push(rowObj);
}
var _jsonString = JSON.stringify(rs);
答案 0 :(得分:0)
看起来您正在尝试获取列表/记录字段的文本和ID。对于一些通用代码(你不知道你是否有列表/记录结果)我做这样的事情:
var _searchId = 'customsearch_pm_item_record_loader';
//itemFilters.push(new nlobjSearchFilter('displayName',null, 'contains', _searchTerm )); //
var rs = nlapiSearchRecord('item', _searchId, itemFilters, columns);
function getResolver(result){
return function(fld,join,agg){
var txt = result.getText(fld,join,agg);
if(txt) return {
id: result.getValue(fld,join,agg),
value:txt;
};
return result.getValue(fld,join,agg);
};
}
var retObj = [];
for (var i = 0; rs != null && i < rs.length; i++) {
var resolve = getResolver(rs[i]);
retObj.push({
id : rs[i].getId(),
custitem_dwr_co_dis : resolve('custitem_dwr_co_dis'),
salesdescription : resolve('salesdescription'),
displayName : resolve('displayName'),
itemid : resolve('itemid'),
unitPrice : resolve('unitprice', 'pricing'), // unit price
basePrice : resolve('baseprice'),
productImage : resolve('custitem50')
});
}
var _jsonString = JSON.stringify(retObj);