Hi,
I am trying to search for all transactions and delete them. The problem is that my search is returning multiple records/lines with the same internalid. My idea was to search the transactions by type, loop though the results and delete them.
I was first used the following code (note there is no grouping) when I descovered the multiple duplicate id's returned:
//search for all transactions based on Type matching deleteTypeArr index var tranType = "SalesOrd"; var tranFilter = new nlobjSearchFilter('type', null, 'anyof',tranType); var tranCol = [new nlobjSearchColumn('internalid')]; var tranResults = nlapiSearchRecord('transaction',null,tranFilter,tranCol); //loop through results for(resultIndex=0;resultIndex<tranResults.length;resultIndex++){ logger.debug('Deletion', 'id= '+tranResults[resultIndex].getValue('internalid')); } So I decided to add a group function to the searchColumn but now when I use getValue('internalid') it returns null. Why is this?Here is my code: //search for all transactions based on Type matching deleteTypeArr index var tranType = "SalesOrd"; var tranFilter = new nlobjSearchFilter('type', null, 'anyof',tranType); var tranCol = [new nlobjSearchColumn('internalid',null,'group')]; var tranResults = nlapiSearchRecord('transaction',null,tranFilter,tranCol); //loop through results for(resultIndex=0;resultIndex<tranResults.length;resultIndex++){ logger.debug('Deletion', 'id= '+tranResults[resultIndex].getValue('internalid')); } I have tried filtering by tranid and using getId() and nothing makes a difference. When I setup a saved search via the GUI it returns the filtered results perfectly. I guess an option would be to further filter a saved search on Transactions by Type, but I would still like to know why the above does is not working.Any help would be much appreciated. Thanks.