I need help to change the undefine values from Sheets.Spreadsheets.Values.get() to null values. Because I want to use the values to make a IF condition.
The case: I want to copy and paste the data on Column 1 - 57 from other spreadsheet using Google API with some condition if the data on column 55 is not null and column 56 is null. At the end, I want to sort the value by column 57 (date). There are 60 Columns and 13k+ rows.
This is my code: (Still having a error because of the undefine value)
function myFunction() {
const sourceid = 'Spreadsheet ID'
const targetid = 'Spreadsheet ID';
const source_range = "Source File!A2:BE";
const destination_range = "Target File!A2:BE"
const data = Sheets.Spreadsheets.Values.get(srcSpreadsheetId, source_range).values;
const arr = [];
for (let i in data) {
if (data[i][55] !== '' && data[i][56] == '') {
arr.push(data[i]);
}
}
var values = {
'valueInputOption': 'USER_ENTERED',
'data': [
{
'range': 'Target File!A2:BE',
'majorDimension': 'ROWS',
'values': arr
}
]
};
Sheets.Spreadsheets.Values.update({ values: values }, targetid, destination_range, { valueInputOption: "USER_ENTERED" });
//sorting method (have not been made);
}