Google Script: Play Sound when a specific cell change the Value

后端 未结 2 746
花落未央
花落未央 2020-12-06 15:10

Situation:

Example Spreadsheet

Sheet: Support
Column: H has the following function \"=IF(D:D>0;IF($B$1>=$G:G;\"Call

2条回答
  •  一整个雨季
    2020-12-06 15:25

    This is a pretty tough problem, but it can be done with a sidebar that periodically polls the H column for changes.

    Code.gs

    // creates a custom menu when the spreadsheet is opened
    function onOpen() {
      var ui = SpreadsheetApp.getUi()
        .createMenu('Call App')
        .addItem('Open Call Notifier', 'openCallNotifier')
        .addToUi();
    
      // you could also open the call notifier sidebar when the spreadsheet opens
      // if you find that more convenient
      // openCallNotifier();
    }
    
    // opens the sidebar app
    function openCallNotifier() {
      // get the html from the file called "Page.html"
      var html = HtmlService.createHtmlOutputFromFile('Page') 
        .setTitle("Call Notifier");
    
      // open the sidebar
      SpreadsheetApp.getUi()
        .showSidebar(html);
    }
    
    // returns a list of values in column H
    function getColumnH() {
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Support");
    
      // get the values in column H and turn the rows into a single values
      return sheet.getRange(1, 8, sheet.getLastRow(), 1).getValues().map(function (row) { return row[0]; });
    }
    

    Page.html

    
    
      
        
      
      
        

    Checking for calls...

    Some sources to help:

    • Sidebars and Dialogs
    • Custom Menus
    • Simple Trigger - onOpen
    • `google.script.run.withSuccessHandler(callback).customFunction()
    • Array.prototype.map

提交回复
热议问题