Any mechanism to send charts via email?

Keith,

Here’s the snippet you were looking for - note that instead of installing the Coda Google Apps Script SDK into the sheet as a library, I copied and pasted the SDK into a separate script. This makes it possible to call functions directly without the library prefix they show in the SDK documentation.

You can see this exact code in operation in this demo.

//
// get coda table data
//
function testGetCodaTableData()
{
  var tableName = "Tutorial Data";
  var tableName = "Table 1";
  var results = getCodaTableData_(tableName);
  Logger.log(JSON.stringify(results[0]));
}
function getCodaTableData_(tableName)
{
  
  // authenticate with coda
  authenticate(codaAPIToken);
  
  // define the document/table
  var documentName = "Airborne Briefing System";
  var sectionName  = "Briefing Report System";
  var docID        = "";
  var tableID      = "";
  
  var aDocs = listDocs().items;
  // Logger.log(JSON.stringify(aDocs));
  for (var i in aDocs)
  {
    
    // is this the name we want?
    if (aDocs[i].name == documentName)
    {
      docID = aDocs[i].id; 
      // Logger.log(docID + " :: " + aDocs[i].name);
      break;
    }
  }
  
  var aTables = listTables(docID).items;
  // Logger.log(JSON.stringify(aTables));
  for (var i in aTables)
  {
    // is this the name we want?
    if (aTables[i].name == tableName)
    {
      tableID = aTables[i].id; 
      break;
    }
  }
  
  // get the data from coda doc
  var aData = listRows(docID, tableID, {limit: 100}).items;
  Logger.log(aData.length);
  
  return(aData);
  
}
3 Likes