Skip to content
Gallery
Getting Started Guide: Coda API
Share
Explore
Config

icon picker
Solutions

These samples are defined here because Coda formulas are currently-single line and it's hard to make multi-line outputs without bulleted lists. We're working on it!
Unsolved Placeholder:
// TODO(Anonymous): implement.
Solutions
Name
Original Value
Value
1
Create Doc
var doc = CodaAPI.createDoc({title: 'Coda API Starter Tutorial'}); Logger.log('New doc created! %s', prettyPrint(doc, null, 2));
var doc = CodaAPI.createDoc({title: 'Coda API Starter Tutorial'}); Logger.log('New doc created! %s', prettyPrint(doc, null, 2));
2
List Tables
var tables = CodaAPI.listTables(DOC_ID); Logger.log('Doc tables are: %s', prettyPrint(tables));
var tables = CodaAPI.listTables(DOC_ID); Logger.log('Doc tables are: %s', prettyPrint(tables));
3
List Columns
var columns = CodaAPI.listColumns(DOC_ID, TABLE_ID); Logger.log('Columns are: %s', prettyPrint(columns, null, 2));
var columns = CodaAPI.listColumns(DOC_ID, TABLE_ID); Logger.log('Columns are: %s', prettyPrint(columns, null, 2));
4
Get Desired Cities
var rowsResponse = CodaAPI.listRows(DOC_ID, TABLE_ID); var cities = []; for (var row of rowsResponse.items) { cities.push(row.values[CITY_COLUMN_ID]); } Logger.log('Fetched cities from Coda: %s', prettyPrint(cities)); return cities;
var rowsResponse = CodaAPI.listRows(DOC_ID, TABLE_ID); var cities = []; for (var row of rowsResponse.items) { cities.push(row.values[CITY_COLUMN_ID]); } Logger.log('Fetched cities from Coda: %s', prettyPrint(cities)); return cities;
5
Satellite Final
var cities = getDesiredCities(); var rows = []; for (var city of cities) { var satImage = getSatelliteImageUrl(city); rows.push({ cells: [ {column: CITY_COLUMN_ID, value: city}, {column: IMAGE_URL_COLUMN_ID, value: satImage}, ], }); } var body = { rows: rows, keyColumns: [CITY_COLUMN_ID], }; CodaAPI.upsertRows(DOC_ID, TABLE_ID, body);
var cities = getDesiredCities(); var rows = []; for (var city of cities) { var satImage = getSatelliteImageUrl(city); rows.push({ cells: [ {column: CITY_COLUMN_ID, value: city}, {column: IMAGE_URL_COLUMN_ID, value: satImage}, ], }); } var body = { rows: rows, keyColumns: [CITY_COLUMN_ID], }; CodaAPI.upsertRows(DOC_ID, TABLE_ID, body);
There are no rows in this table
5
Count
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.