Why is my array not passed to cells with setValues()

Viewed 39

I am trying to filter information on different tables by finding values on them, but when I try to .setValues() nothing happens.

I'm receiving no error in the console.

function GetDrops() {
  // Sheets Variables
  var mobItemDB = SpreadsheetApp.getActiveSpreadsheet()
  var mobDB = mobItemDB.getSheetByName('mobDB')
  var itemDB = mobItemDB.getSheetByName('itemDB')
  var itemDBLastRow = itemDB.getLastRow()
  var itemDBLastColumn = itemDB.getLastColumn()
  var itemArray = itemDB.getRange(8,1,itemDBLastRow-7,itemDBLastColumn).getValues()

  // Drops by Row
  var dropsA1 = mobDB.getRange(3,37,1,26).getValues()
  var dropsB1 = [dropsA1[0][0], dropsA1[0][2], dropsA1[0][4], dropsA1[0][6], dropsA1[0][8], dropsA1[0][10], dropsA1[0][12], dropsA1[0][14], dropsA1[0][16], dropsA1[0][18], dropsA1[0][20], dropsA1[0][22], dropsA1[0][24]]
  
  // Filtered Tabs
  var loot = mobItemDB.getSheetByName('3 Loot')
    var lootLastRow = loot.getLastRow()
  var lootType = 3

  // Find Drops
  var searchV = dropsB1
  var matchRow = itemArray.find(r => r[0] == searchV[0])
  var match = matchRow ? matchRow : ""
  
  // Filter Items
  if(match[3][0] == lootType) {
    loot.getRange(lootLastRow+1,1,1,58).setValues(match)
  }

  // Console
  console.log(match)
}

If I change if(match[3][0] == lootType) to if(match[3] == lootType) I get error The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues.

My debug console shows 'match' with exactly the values that I need to pass to '3 Loot' sheet, but when the script finishes the cells continue to be blank:

Debug Screenshot

1 Answers

As a guess. Try to change:

loot.getRange(lootLastRow+1,1,1,58).setValues(match)

to:

loot.getRange(lootLastRow+1,1,1,58).setValues([match])
Related