How to search Array objects within the Spreadsheet of Google Apps Script and compare with another spreadsheet?

Asked

Viewed 21 times

0

I created a code where the number of Arrays is variable within an order control sheet! And I need to take the objects of this variable spreadsheet and check if the objects (product name) match with another spreadsheet (that is the Stock). If they do, I need that the quantity of products of the order made subtracts the stock sheet.

Follows the code:

function controleEstoque (){
 
var app = SpreadsheetApp;
var wareControl = app.openByUrl('A URL está aqui');
var billingSheet = app.getActiveSpreadsheet();

var abaWC = wareControl.getActive();
var wcLastRow = abaWC.getRange ('A9').getDataRegion().getLastRow();

var abaBilling = billingSheet.getSheetByName('Pedidos');
var billingLR = abaBilling.getRange('C24').getDataRegion().getLastRow();

var arrayPBR = [];

for (var x = 25; x<= billingLR; x++) {
  
 var PBR = abaBilling.getRange(x, 3).getValue();
 arrayPBR.push(PBR);
 }
}

With these commands I managed to take the last row of the spreadsheet and play all the values that vary within the Array. But now I stopped because I don’t know how to compare the values inside the Array to the values inside the stock sheet.

Does anyone know, how I can create this value comparison, using objects within an Array?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.