To get all the child records of a customer via script, we can use nlapiSearchRecord api. We just need to use joined searches.
Below is a sample script that captures all the children of a customer record.
function getChildren(){
var filters = new Array();
// 915 is the internal id of the parent customer
filters[0] = new nlobjSearchFilter('internalid', 'parentcustomer', 'anyof', '915');
var columns = new Array();
columns[0] = new nlobjSearchColumn('internalid');
var results = nlapiSearchRecord('customer',null, filters, columns);
//results would be an array of the internal ids of the child customers
for (var i=0; i<results.length; i++){
nlapiLogExecution('DEBUG','Child #'+i,results[i].getValue('internalid'));
}
}
No comments:
Post a Comment