Has anyone used the N/Query module with custom rec...
# suitescript
m
Has anyone used the N/Query module with custom records? Maybe I'm fundamentally misunderstanding how the module works (possible!), but I'm trying to add a join to a component and it's not working. If I uncomment these lines it doesn't work:
Copy code
var ex_query = query.create({type: 'customrecord_example'});
        var ex_query_customer = ex_query.autoJoin({fieldId: 'custrecord_ex_customer'});
        var ex_query_vendor = ex_query.autoJoin({fieldId: 'custrecord_ex_record'});
        //var ex_query_vendor_details = ex_query_vendor.joinTo({fieldId: 'custrecord_ex_r_item', target: 'custrecord_ex_record'});
        

        ex_query.columns = [
            ex_query.createColumn({fieldId: 'id'}),
            ex_query_customer.createColumn({fieldId: 'id'}),
            ex_query_vendor.createColumn({fieldId: 'name'}),
            // ex_query_vendor_details.createColumn({fieldId: 'department'}),
            // ex_query_vendor_details.createColumn({fieldId: 'class'}),
            // ex_query_vendor_details.createColumn({fieldId: 'location'})
        ]

        var ex_results = ex_query.run();

        for (ex_idx in ex_results.results) {
            log.debug({title: 'Found', details: JSON.stringify(ex_results.results[ex_idx])});
        }
I get the following error message:
SSS_SEARCH_ERROR_OCCURRED {"type":"error.SuiteScriptError","name":"SSS_SEARCH_ERROR_OCCURRED","message":"Search error occurred: Record Join 'custrecord_ex_r_item^custrecord_ex_record' for record 'CUSTOMRECORD_EX_RECORD' was not found.","stack":["run(N/query.js)","<anonymous>(adhoc$-1$debugger.user:22)","<anonymous>(adhoc$-1$debugger.user:5)"],"cause":{"type":"internal error","code":"SSS_SEARCH_ERROR_OCCURRED","details":"Search error occurred: Record Join 'custrecord_ex_r_item^custrecord_ex_record' for record 'CUSTOMRECORD_EX_RECORD' was not found.","userEvent":null,"stackTrace":["run(N/query.js)","<anonymous>(adhoc$-1$debugger.user:22)","<anonymous>(adhoc$-1$debugger.user:5)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
22 refers to the .run() line.