[英]How to create saved search in netsuite by joining two records using left outer join in SuiteScript 2.0
i want to create an search by joining two records using the left outer join in "suitescript 2.0 version" 我想通过使用“ suitescript 2.0版本”中的左外部联接来联接两个记录来创建搜索
first record is an standard record (invoice) and the second record is an custom record(contract) both records having common fields namely:class and transaction type,owner. 第一条记录是标准记录(发票),第二条记录是自定义记录(合同),这两个记录具有相同的字段,即:类别和交易类型,所有者。
Invoice Record fields are the Transaction Column fields (class,transaction type,owner) Contract Record Fields are the custom fields(class,transaction,owner) 发票记录字段是“交易列”字段(类,交易类型,所有者)合同记录字段是自定义字段(类,交易类型,所有者)
I have created search for the Invoice Record and based on the search results of the Invoice Record ,I have created the Search on the contract record. 我已经创建了对发票记录的搜索,并根据发票记录的搜索结果在合同记录上创建了搜索。 my code is giving the correct results but question is "it possible to create an search for two different records using left outer join in SuiteScript 2.0 version?"
我的代码给出了正确的结果,但问题是“是否可以在SuiteScript 2.0版本中使用左外部联接来创建两个不同记录的搜索?”
//Create Search on Standard Invoice Record
var mySearch = search.create({
type: 'invoice',
columns: ['internalId', 'item', 'line', 'custcol_class', 'custcol_transaction_type', 'custcol_owner', 'amount'],
filters: ['trandate', 'after', '12/15/2015']
});
//Executing the First 100 records on the search result
var searchResult = mySearch.run().getRange(0, 100);
log.debug('Search Length', searchResult.length);
for (var i = 0; i < searchResult.length; i++) {
var lineId = searchResult[i].getValue({
name: 'line'
});
var item = searchResult[i].getValue({
name: 'item'
});
var contractClass = searchResult[i].getValue({
name: 'custcol_class'
});
var transactionType = searchResult[i].getValue({
name: 'custcol_transaction_type'
});
var owner = searchResult[i].getValue({
name: 'custcol_owner'
});
var invoice_id = searchResult[i].getValue({
name: 'internalId'
});
var invoice_amt = searchResult[i].getValue({
name: 'amount'
});
log.debug('Values', 'contractClass:' + contractClass + '-transactionType:' + transactionType + '-owner:' + owner);
if (contractClass != '' && owner != '' && transactionType != '') {
log.debug('create commision', 'item' + item + '-lineId:' + lineId + '-contractClass:' + contractClass + '-transactionType:' + transactionType + '-owner:' + owner);
createCommission(contractClass, transactionType, owner, invoice_id, invoice_amt);
}
}
}
function createCommission(contractClass, transactionType, owner, invoiceId, invoice_amt) {
log.debug('Entry', 'createCommission Initiated');
log.debug('invoice amount..', invoice_amt);
//Creating search on Custom Record Contract
var mySearch = search.create({
type: 'customrecord_contract',
columns: ['internalId', 'custrecord_rec_class', 'custrecord_vendor_fees_formula'],
filters: [
['custrecord_rec_class', 'anyof', contractClass], 'AND', ['custrecor_rec_transaction_type', 'anyof', transactionType], 'AND', ['custrecord__rec_owner', 'anyof', owner], 'AND', ['custrecord__vendor_fees_formula', 'anyof', INRAM_RS_V1]
]
});
}
Thanks in advance 提前致谢
Unfortunately this is not currently possible with NetSuite. 不幸的是,NetSuite目前无法做到这一点。
You will have to settle for writing a function that takes in both sets of results and combines them accordingly. 您将需要编写一个可以同时接收两组结果并相应地将它们组合在一起的函数。 If you use any array utility libraries like lodash, you could use something like
_.groupBy
to make the combination simpler. 如果使用诸如lodash之类的任何数组实用程序库,则可以使用
_.groupBy
类的_.groupBy
来简化组合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.