For this particular case, I have data coming from a Google Sheet (4Cat) that is being transferred to another sheet (ImportFeeder) where my Google Script is executed.
After executing the script provided below, I am looking to implement a filter script at the end to organize the data by Row K (only displaying iPad products).
https://i.sstatic.net/GqckL.jpg
function myFunction() {
var sss = SpreadsheetApp.openById('1kL96dRm3Z8XBtMXnSzUARxR1b34-njlkZQ1sU0c3g1s'); //update with source ID
var ss = sss.getSheetByName('4cat'); //update with source Sheet tab name
var range = ss.getRange('A:I'); //defining the range you want to copy
var data = range.getValues();
var tss = SpreadsheetApp.openById('1u7547KaniKHLUJn2v-ezN4l8ZcxE4viCFcoxsA904MI'); //update with destination ID
var ts = tss.getSheetByName('Sheet1'); //update with destination Sheet tab name
ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length).setValues(data);
var range = ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length)
var rawData = range.getValues() // retrieve values from spreadsheet 2
var data = [] // Filtered Data will be stored in this array
for (var i = 0; i< rawData.length ; i++){
if(rawData[i][10] == "iPad") // Check to see if column K has iPad, if not skip it
{
data.push(rawData[i])
}
}
}
(Cannot read property length from undefined)
4Cat Sample Data https://docs.google.com/spreadsheets/d/1kL96dRm3Z8XBtMXnSzUARxR1b34-njlkZQ1sU0c3g1s/edit?usp=sharing */
feeding into
ImportFeeder https://docs.google.com/spreadsheets/d/1u7547KaniKHLUJn2v-ezN4l8ZcxE4viCFcoxsA904MI/edit?usp=sharing
Required - Successful import of data between sheets, filtering based on Row K within Google Scripts. Include a clear() function at the beginning of the script to ensure the sheet is cleared before each daily import process.