Suitescript搜索与自定义父/子记录连接

时间:2016-01-04 11:52:15

标签: netsuite suitescript

全晚,

我正在使用我的第一个搜索脚本加入,我无法在我的生活中获取parent信息以在控制台中显示任何内容(显示为null)。我知道我遗漏了一些非常基本的东西。

搜索代码如下:

        var parent = 'customrecordvendorpricereview';   // custom parent record
        var child  = 'customrecordvpri_reviewitems';    // custom child record
        var join   = 'custrecordvpri_header';           // field on the child record which points to the parent record

        var filters = new Array();
            filters[0] = new nlobjSearchFilter('custrecordvpr_processed',join,'is','T' );                 log(filters[0]);// check if the review is ready to process
            filters[1] = new nlobjSearchFilter('custrecordvpr_completed',join,'is','F' );                 log(filters[1]);// check if the review has not already been processed
            filters[2] = new nlobjSearchFilter('custrecordvpr_cancelreview',join,'is','F' );              log(filters[2]);// check if the review has been cancelled.
            filters[3] = new nlobjSearchFilter('custrecordvpr_effectivedate',join,'within','thisWeek' );  log(filters[3]);// check if the review is effective within the last week.
        var columns = new Array();
            columns[0]  = new nlobjSearchColumn('internalid',join);                                       log(columns[0]);// VPR Review Header Record ID
            columns[1]  = new nlobjSearchColumn('custrecordvpr_supplier',join );                          log(columns[1]);// VPR Review Supplier
            columns[2]  = new nlobjSearchColumn('custrecordvpr_effectivedate',join );                     log(columns[2]);// VPR Effective Date
            columns[3]  = new nlobjSearchColumn('custrecordvpr_thisrate',join );                          log(columns[3]);// VPR Exchange rate for this review
            columns[4]  = new nlobjSearchColumn('custrecordvpri_header' );                                log(columns[4]);// VPRI Field ID >> links to parent
            columns[5]  = new nlobjSearchColumn('custrecordvpri_item' );                                  log(columns[5]);// VPRI Item ID 
            columns[6]  = new nlobjSearchColumn('custrecordvpri_vendorcode' );                            log(columns[6]);// VPRI Vendor Code
            columns[7]  = new nlobjSearchColumn('custrecordvpri_prefsupplier' );                          log(columns[7]);// VPRI Preferred Supplier
            columns[8]  = new nlobjSearchColumn('custrecordvpri_newprice' );                              log(columns[8]);// VPRI New Vendor Price
            columns[9]  = new nlobjSearchColumn('custrecordvpri_prefer' );                                log(columns[9]);// VPRI Review vendor is preferred
            columns[10] = new nlobjSearchColumn('custrecordvpri_newstdcost' );                            log(columns[10]);// VPRI New Standard Cost 
            columns[11] = new nlobjSearchColumn('custrecordvpri_stdcostchange' );                         log(columns[11]);// VPRI New Standard Cost Change
            columns[12] = new nlobjSearchColumn('custrecordvpri_salepricechange' );                       log(columns[12]);// VPRI New Sales Price Change
            var res = nlapiSearchRecord( child, null, filters, columns);
            return res;

我非常感谢对这方面的一些澄清,因为文档可能有点含糊不清。

此外,当我删除过滤器时,我会获取所有子记录数据,但父字段显示为null。

1 个答案:

答案 0 :(得分:0)

好的,我发现了错误,我需要添加'加入'到getValue。过滤器是正确的,只有一个T / F字段排除了所有数据。