Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions utils/logging.gs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
*/

// [START apps_script_logging_execution_time]
/**
* A placeholder function to be timed.
* @param {Object} parameters
*/
function myFunction(parameters) {
// Placeholder for the function being timed.
}

/**
* Logs the time taken to execute 'myFunction'.
*/
Expand Down Expand Up @@ -51,15 +59,10 @@ function measuringExecutionTime() {
*/
function emailDataRow(rowNumber, email) {
console.log('Emailing data row ' + rowNumber + ' to ' + email);
try {
const sheet = SpreadsheetApp.getActiveSheet();
const data = sheet.getDataRange().getValues();
const rowData = data[rowNumber - 1].join(' ');
console.log('Row ' + rowNumber + ' data: ' + rowData);
MailApp.sendEmail(email, 'Data in row ' + rowNumber, rowData);
} catch (err) {
// TODO (developer) - Handle exception
console.log('Failed with error %s', err.message);
}
const sheet = SpreadsheetApp.getActiveSheet();
const data = sheet.getDataRange().getValues();
const rowData = data[rowNumber - 1].join(' ');
console.log('Row ' + rowNumber + ' data: ' + rowData);
MailApp.sendEmail(email, 'Data in row ' + rowNumber, rowData);
}
// [END apps_script_logging_sheet_information]
3 changes: 2 additions & 1 deletion utils/test_logging.gs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function populateValues(spreadsheetId) {
const batchUpdateRequest = Sheets.newBatchUpdateSpreadsheetRequest();
const repeatCellRequest = Sheets.newRepeatCellRequest();

/** @type {string[][]} */
const values = [];
for (let i = 0; i < 10; ++i) {
values[i] = [];
Expand All @@ -54,7 +55,7 @@ function itShouldEmailDataRow() {
const email = Session.getActiveUser().getEmail();
const spreadsheetId = createTestSpreadsheet();
populateValues(spreadsheetId);
const data = Spreadsheet.openById();
const data = SpreadsheetApp.openById(spreadsheetId);
emailDataRow(1, email);
}

Expand Down
Loading