I'm in the middle of writing a Suitelet and am having a little trouble. I have two searches run. One gets all contract items for a customer (custom record) and the other gets all sales data for the past 12 months. I then cycle through all items that have had sales, and write an HTML row with the Item # and Sold QTY. I then iterate through the contract items to see if that item is listed and also include that in the table row. Then process the next item.
The problem I'm having is that if an item has not had any sales, but is listed in the contract, it does not show up in my table. What I'd like to do is after I iterate through all items sold, I'd like to go back to the contract items and find out which have not been added to the table.
My through process was:
- When iterating through sales data and checking to see if there is also a match in the contract items, FLAG THE ITEM AS BEING PROCESSED.
- After going through all item's sales data, go through all contract items and see which ones haven't been flagged. If it hasn't been flagged, write it to a new row in the HTML table.
My array would look like:
[CPM ID], [ITEM #], [CONTRACT_PRICE], [EFFECTIVE_DATE], [EXPIRATION_DATE]
[1234], [12312], [.0256], [1/1/2016], [12/31/2016]
[4321], [44556], [.0789], [1/1/2016], [12/31/2016]
[5566], [77889], [.0112], [1/1/2016], [12/31/2016]
I'd like to be able to add another column after the search runs and then when processing through items, fill the new field with a true value
[CPM ID], [ITEM #], [CONTRACT_PRICE], [EFFECTIVE_DATE], [EXPIRATION_DATE], [PROCESSED]
[1234], [12312], [.0256], [1/1/2016], [12/31/2016], [true]
[4321], [44556], [.0789], [1/1/2016], [12/31/2016],
[5566], [77889], [.0112], [1/1/2016], [12/31/2016], [true]
Is this possible? Am I going about this the wrong way, altogether?
// WRITE HTML TABLE HEADERS // ITEM, QTY SOLD, CPM_ID, CPM Price, CPM Effective, CPM Expiration for (var i = 0; i < usageResults.length; i++) { var currItem = usageResults[i].getValue('item', null, 'group'); var foundFlag = false; //WRITE HTML TABLE ROW // ITEM #, QTY SOLD for (var j=0; j < cpmResults.length; j++) { // IF A MATCH IS FOUND IN THE CONTRACT PRICING if (cpmResults[j].getValue('custrecord_contract_pricing_item') == usageResults[i].getValue('item', null, 'group')) { // INCLUDE THE CONTRACT INFORMATION IN THE SAME ROW // CPM_ID, CPM Price, CPM Effective, CPM Expiration foundFlag = true; //THIS IS WHERE I BELIEVE I NEED TO ADD DATA TO A NEW COLUMN TO MARK THE INDEX OF THE ARRAY AS BEING PROCESSED } // IF PROCESSING THE LAST ROW AND IT DOES NOT CONTAIN DATA, FILL IN EMPTY CELLS if (foundFlag == false && j == cpmResults.length -1) { htmlOutput += '<td></td><td></td><td></td><td></td><td></td><td></td></tr>'; } //EXIST LOOP IF A MATCH WAS FOUND if (foundFlag) continue; } } // HOW THE HECK CAN I NOW PROCESS EVERYTHING THAT DIDN'T HAVE A MATCH?