Ana Karina Puga
Ana Karina Puga

Reputation: 11

Playing a sound when a new entry is done on Google sheet

Is there a way to play a sound whenever there is new data entered by a user in certain cell? The use case is to give a sound notification to the user just like Uber app gives a sound notification to the driver when there is a ride request.

More specifically: when Col_1 has been changed, my code records day and hour of this change in Col_2. I need my code also notify of this change with a sound in real time.

This is my code:

function onEdit(event){

  var Col_1 = 11;
  var Col_2 = 12;

  var changedRange = event.source.getActiveRange();
  if (SpreadsheetApp.getActiveSheet().getName() == "Planilla madre") {
  if (changedRange.getColumn() == Col_1) {
    var state = changedRange.getValue();
    var adjacent = event.source.getActiveSheet().getRange(changedRange.getRow(),Col_2);
    var timestamp = new Date();
    switch (state) {
      case "":
        // 
        adjacent.clearContent();
        break;
      default:
        // 
        adjacent.setValue(timestamp);
        break
    }
    }
  }
}

Upvotes: 1

Views: 3245

Answers (1)

Raserhin
Raserhin

Reputation: 2686

As right now there seems to be no way to actually play sound the way you want.

You could look at this question but this will need to actually create an HTML page to display it as dialog. Using Audio seems to not work either in Apps Script.

But sincerely to create a dialog to serve HTML with audio the solution of @IMTheNachoMan and using toast to show a little pop out for every edit you want to notify.

Upvotes: 1

Related Questions