user1098767
user1098767

Reputation: 91

How can I get this return data into dynamic arrays?

Working with regular javascript, I need to store info into an array for output where Cust ID is the same. So the result data:

Tran ID         Name                               Cust ID          Brand          Tran Date
16446     |     Denton Bible Church      |     8381     |      Epson     |      8/27/2009
124751   |     Denton Bible Church      |     8381     |      Da-Lite    |     10/27/2010

My javascript to get column data:

for ( var z = 0; z < records.length; z++ ) {
        var result = records[z];
        var columns = result.getAllColumns();
        var column = columns[3];
        var brands = result.getValue(column);
        nlapiLogExecution('DEBUG','brands',brands);

        column = columns[2];
        var internalid = result.getValue(column);
        nlapiLogExecution('DEBUG','internalid',internalid);

        column = columns[4];
        var orderdate = result.getValue(column);
        nlapiLogExecution('DEBUG','orderdate',orderdate);

        var boresult = orderdate + "-" + brands;

        //The above would be inserted into the customer field for 1 customer

        //nlapiSetFieldValue('custentity28',brands + "-" + orderdate);
        nlapiSubmitField('customer', internalid, 'custentity28', boresult);
        nlapiLogExecution('DEBUG','enter','enter');
          }

I'm using API from my accounting software so the functions may not make sense. Anyway, so I need to know how to say: For every Cust ID that is the same, create an array and store in the following format:

8/27/2009 - Epson
10/27/2010 - Da-Lite

You can see I tried to do that with the boresult variable but I think that would only be pulling in the first line right?

Upvotes: 0

Views: 124

Answers (1)

alextercete
alextercete

Reputation: 5151

You probably should create an array outside the loop and just push items into it:

var boresults = [];

for (var z = 0; z < records.length; z++) {

    // Some code here...        

    var boresult = orderdate + "-" + brands;
    boresults.push(boresult);

    // Some other code...
}

Upvotes: 1

Related Questions