0

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
    }
    }
  }
}
Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    You want the computer to go "ding" or whatever each time someone enters info into a cell? Did this not work? -> https://stackoverflow.com/questions/40881605/google-script-play-sound-when-a-specific-cell-change-the-value if not please show your code so we can find the problem. If it does work, delete this question. If I don't understand what you are asking, clarify your question. – Rodger Mar 04 '20 at 01:06
  • 1
    Thanks for your answer! I clarified my question. – Ana Karina Puga Mar 04 '20 at 01:58
  • Have you thought about using SpreadsheetApp's `toast` function to show a little toast slide out notification? Many users mute audio, can't hear, or don't like audio notifications. – IMTheNachoMan Mar 04 '20 at 03:54

1 Answers1

1

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.

Raserhin
  • 2,516
  • 1
  • 10
  • 14