netsuitesuitescriptsuitecommerce

How can i get itemfulfillment search without repetition/duplication


I am executing nlapiSearchRecord function on itemfulfillment record and the search is working fine but its return result with repetition/duplicate. Below is the my working code i just want to know that which filter should i use to avoid repetition/duplicate record.

 var filters = [
                    new nlobjSearchFilter('internalid', null, 'is',id),
                    new nlobjSearchFilter('mainline', null, 'is', 'F'),
                    new nlobjSearchFilter('shipping', null, 'is', 'F'),
                    new nlobjSearchFilter('taxline', null, 'is', 'F')

                    ], columns = [
                        new nlobjSearchColumn('trandate'), 
                        new nlobjSearchColumn('tranid'), 
                        new nlobjSearchColumn('item'),
                        new nlobjSearchColumn('quantity'),
                        new nlobjSearchColumn('location')                            
                    ];

                    var searchresults = lapiSearchRecord('itemfulfillment',null, filters, columns);

Below is the search result for your understanding and you can see that there is one item but it's is duplicated two times with positive quantity and one time with negative quantity.

[{"id":"123","recordtype":"itemfulfillment", "columns":{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxxx","internalid":"xxxx"},"item":{"name":"Test-1","internalid":"1111"},"quantity":1,"location":{"name":"xxxx","internalid":"xxx"}}}, {"id":"123","recordtype":"itemfulfillment", "columns":{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxxx","internalid":"xxxx"},"item":{"name":"Test-1","internalid":"1111"},"quantity":1,"location":{"name":"xxxx","internalid":"xxx"}}},{"id":"123","recordtype":"itemfulfillment", "columns":{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxxx","internalid":"xxxx"},"item":{"name":"Test-1","internalid":"xxxx"},"quantity":-1,"location":{"name":"xxxx","internalid":"xx"}}},{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxxx","internalid":"xxxx"},"item":{"name":"XXXXX","internalid":"1111"},"quantity":1,"location":{"name":"xxxx","internalid":"xxx"}}}, {"id":"123","recordtype":"itemfulfillment", "columns":{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxx","internalid":"xxxx"},"item":{"name":"Test-2","internalid":"xyz"},"quantity":2,"location":{"name":"xxx","internalid":"xxxx"}}},{"id":"123","recordtype":"itemfulfillment","columns":{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxxx","internalid":"xxxx"},"item":{"name":"Test-2","internalid":"xyz"},"quantity":2,"location":{"name":"xxxx","internalid":"10"}}},{"id":"123","recordtype":"itemfulfillment", "columns":{"trandate":"2/1/2222","tranid":"xx-xxxx","status":{"name":"xxxx","internalid":"xxxx"},"item":{"name":"Test-2","internalid":"xyz"},"quantity":-2,"location":{"name":"xxxx","internalid":"xxxx"}}}]

Can you please guide me that how can i get items without any repetition/duplication.


Solution

  • The positive and negative quantities relate to the G/L entries created by the fulfillment.

    Choose the G/L account for the side of the transaction you are interested in as another filter.