简体   繁体   English

如何通过使用SuiteScript 2.0中的左外部联接联接两个记录来在netsuite中创建保存的搜索

[英]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.

相关问题 NetSuite:在SUITESCRIPT 2.0中使用SUITESCRIPT 1.0 - NetSuite: Using SUITESCRIPT 1.0 inside of SUITESCRIPT 2.0 用于将保存的搜索转换为 csv 的 Netsuite suitescript - Netsuite suitescript for converting saved search to csv 如何在netsuite中使用suitescript创建自定义记录? - How can I create custom records with suitescript in netsuite? 如何使用 SuiteScript 2.0 重新安排 Netsuite 中的调度脚本 - How to Reschedule the Schedule Script in Netsuite using SuiteScript 2.0 version 如何在SuiteScript 2.0版本中创建搜索 - How to create a Search in SuiteScript 2.0 version 如何在SuiteScript 2.0版本中使用带有NVAL2函数的“筛选条件”作为公式日期字段来创建搜索 - How to create an search using the Filter Condition as an Formula Date Field with NVAL2 Function in SuiteScript 2.0 version 如何在 netsuite 中使用 suitescript 2.0 在没有堆栈跟踪的情况下显示自定义错误消息 - How to show the custom error message without stack trace using suitescript 2.0 in netsuite 如何使用SuiteScript 2.0将文件从本地上传到NetSuite文件柜 - How to upload a file from local to NetSuite file cabinet using SuiteScript 2.0 如何使用suitescript 2.0动态加载/提供netsuite子列表中类型列表/记录的记录? - How to dynamically load/source a record for type list/record in netsuite sublist using suitescript 2.0? netsuite suitescript 2.0版如何设置多选字段的值? - How to set value for the multi-select field using netsuite suitescript 2.0 version?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM