How Purchase Order created in NetSuite load?

629 views Asked by At

I have a javascript function to load the list of all that are created Purchase Order, these Purchase Orders are componene Vendor, Items (id item, quiantity item, item amount), Form, Currency, Trandate. When fetching data, it does function properly but gives me more corresponding records, that gives me the result is as follows:

Para Purchase Order: ID Purchase Order: 3505 ID Vendor: Servicio de Impuestos Internos ID Item: UNDEF_MX Trandate: 6/8/2015 Form: Standard Purchase Order Currency: Peso CL

Para Purchase Order: ID Purchase Order: 3505 ID Vendor: ID Item: DonaciĆ³n al Proyecto : itemTest Trandate: 6/8/2015 Form: Standard Purchase Order Currency: Peso CL

Para Purchase Order: ID Purchase Order: 3505 ID Vendor: 1234 ID Item: Trandate: 6/8/2015 Form: Standard Purchase Order Currency: Peso CL

This is seen in the log script NetSuite, for each Purchase Order these three results are seen. I just need you to show me:

Para Purchase Order: ID Purchase Order: 3505 ID Vendor: 1234 ID Item: Trandate: 6/8/2015 Form: Standard Purchase Order Currency: Peso CL

the function code is as follows:

function loadPurchaseOrder(){
nlapiLogExecution('DEBUG','loadPurchaseOrder', 'Entra a funcion loadPurchaseOrder');    

var filters = new Array();
filters[0] = new nlobjSearchFilter('purchaseorder',null,'isnotempty');

var columns = new Array();    
columns[0] = new nlobjSearchColumn('item');
columns[1] = new nlobjSearchColumn('entity');
columns[2] = new nlobjSearchColumn('trandate');
columns[3] = new nlobjSearchColumn('customform');
columns[4] = new nlobjSearchColumn('currency');
columns[5] = new nlobjSearchColumn('internalid');

var results = nlapiSearchRecord('purchaseorder',null,filters,columns);
var out = "";

for(var i in results){

    var purchaseOrder = results[i];        
    var idPurchaseOrder = purchaseOrder.getText('internalid');
    var idVendor = purchaseOrder.getText('entity');
    var trandate = purchaseOrder.getValue('trandate');
    var form = purchaseOrder.getText('customform');
    var currency = purchaseOrder.getText('currency');
    var idItem = purchaseOrder.getText('item');

    out = " ID Purchase Order: " + idPurchaseOrder + " ID Vendor: " + idVendor + " ID Item: " + idItem
          + " Trandate: " + trandate + " Form: " + form + " Currency: " + currency;

    nlapiLogExecution('DEBUG','purchaseOrderCargada', 'Para Purchase Order: ' + out);
}

return out;

}

If anyone can help me please.

PS: the out variable that is returned is only test.

2

There are 2 answers

1
user3075978 On BEST ANSWER

You are probably getting three results because there is one one mainline row and one row for each line item in the purchase order.

The mainline row is the amount for the entire transaction. The line item rows are for each item within that transaction.

You just want the mainline, so you will need to add:

    filters.push(new nlobjSearchFilter('mainline', null, 'is', 'T'));
1
Rusty Shackles On

Getting transaction item line info via search since sometimes add duplicate lines. These duplicate lines can be for Tax, Shipping or Accounting impact.

At a mininum, I would suggest adding the following search filters

filters.push(new nlobjSearchFilter('istaxline', null, 'is', 'F'));
filters.push(new nlobjSearchFilter('isshipline', null, 'is', 'F'));

I might have the field ids wrong but that is the concept. If duplicate lines are still showing after adding the following filters, you will need to figure out which accounting impact is causing the issue.

I would suggest replicating the script search in the UI to check if your filters are giving you the desired result.