<@U29PVMVAR> This is what I got so far. ` var NU_B...
# suitescript
s
@erictgrubaugh This is what I got so far.
Copy code
var NU_BO_R = NU_BO_R || {};

<http://NU_BO_R.bo|NU_BO_R.bo> = function (portlet) {

    portlet.setTitle('PO/particulars:');

    var i = 0;
    var ret_cols = [];
    var filters = [];
    //Columns for main PO header row
    ret_cols[0] = new nlobjSearchColumn('tranid');
    ret_cols[1] = new nlobjSearchColumn('entity');
    ret_cols[2] = new nlobjSearchColumn('trandate');
    ret_cols[3] = new nlobjSearchColumn('quantity');
    ret_cols[4] = new nlobjSearchColumn('quantitybilled');
    ret_cols[5] = new nlobjSearchColumn('quantitycommitted');
    ret_cols[6] = new nlobjSearchColumn('quantitypacked');
    ret_cols[7] = new nlobjSearchColumn('quantitypicked');
    ret_cols[8] = new nlobjSearchColumn('quantityrevcommitted');
    ret_cols[9] = new nlobjSearchColumn('quantityshiprecv');
    ret_cols[10] = new nlobjSearchColumn('quantityuom');
    // Search filters
    filters[0] = new nlobjSearchFilter('type', null, 'is', 'PurchOrd:D');
    // Results array
    var results = nlapiSearchRecord('purchaseorder', null, filters, ret_cols);

    for (i = 0; i < 25; i++){
        var ic = 0;
        //ID of record found in results[n]
        var r_id = results[i].getId();
        //PO object
        var po = nlapiLoadRecord('purchaseorder', r_id);
        //Number of items on PO
        var item_n = po.nlapiGetLineItemCount('item');
        // add main PO header columns
        portlet.addRow(results[i]);       
        // add item particulars for results[n] under main PO header
        for (ic = 0; ic < item_n; ic++) {

            var item = po.nlapiGetLineItemValue('item', 'item', ic);   
            var desc = po.nlapiGetLineItemValue('item', 'description', ic);
            var vendorname = po.nlapiGetLineItemValue('item', 'vendorname', ic);
            var i_quantity = po.nlapiGetLineItemValue('item', 'quantity', ic);
            var i_quantitybilled = po.nlapiGetLineItemValue('item', 'quantitybilled', ic);
            var i_quantityreceived = po.nlapiGetLineItemValue('item', 'quantityreceived', ic);  
            var units = po.nlapiGetLineItemValue('item', 'units', ic); 
            var landedcostcategory = po.nlapiGetLineItemValue('item', 'landedcostcategory', ic);
            var inventorydetail = po.nlapiGetLineItemValue('item', 'inventorydetail', ic);
            var createdfrom = po.nlapiGetLineItemValue('item', 'createdfrom', ic);
            var linkedorder = po.nlapiGetLineItemValue('item', 'linkedorder', ic);

            portlet.addRow([['Item', item],['Desc', desc], ['Vender', vendorname],
                            ['Qt', i_quantity], ['Qt/Billed', i_quantitybilled], ['Qt/Rec', i_quantityreceived],
                            ['UOM',units], ['Land/Cost/Cat', landedcostcategory], ['Details', inventorydetail],
                            ['Crt/Frm', createdfrom], ['Lnk/Ord', linkedorder]]);
        }
    }
};
e
ssdevktown: What's your ultimate goal with this code?
s
Dump as much PO info in a Portlet list. Then trim to desired via user input. For backorders and general open po info really.
e
Sorry I've been distracted this afternoon. What's the main problem you're seeing right now?
Couple of things to watch out for that I see immediately: *
nlapiSearchRecord
returns
null
when there are no results, so I typically do
nlapiSearchRecord(...) || [];
The
|| []
forces an empty array instead of
null
* Your
type
filter doesn't look right to me.
PurchOrd:D
looks more like a
status
than a
type
* Your sublist iteration with
ic
starts at
0
, but in SuiteScript 1.0, sublist indices start at
1
. Your loop will need to be
for (ic = 1; ic <= item_n; ic++) { ... }