reactor-gsheet-add-row
Reactor Extension script that adds a row to a Google Sheet spreadsheet each time
an appropriate action is created. The action's customFields
contain an object
whose keys are Sheet column headings, and values are the values for the new row.
Installation
git clone https://github.com/evrythng/reactor-gsheet-add-row
- Copy
main.js
to a Reactor script configuration screen in the EVRYTHNG Dashboard on an application details page. - Set up the configuration values as detailed in Usage below.
Usage
- Create a Google Sheet and note the ID in the URL, or use an existing one.
- Enter the headers in row 1 - these will be
customFields
keys. - Create a Service Account in Google API Console (with Sheets API enabled) and save the credentials JSON file offered.
- Share the Sheet with the Service Account user by email address with the edit permission enabled.
- Set the
SHEET_ID
, then theSECRET_CREDS
in the Reactor script with values from the downloaded JSON file, then save the Reactor script. - Create an action of type
_AddRow
with row data ascustomField
values. An example is shown below:
POST /actions/_AddRow
Content-Type: application/json
Authorization: $TRUSTED_APPLICATION_API_KEY
{
"type": "_AddRow",
"customFields": {
"Index": "1",
"Date": "21/12/18",
"Updated": "28397",
"Deleted": "23"
}
}
The above will result in the following sheet layout (if it was the first row added):
Index Date Updated Deleted
1 21/12/18 28397 23
Each subsequent action will add another row from the first blank row found, from the top of the worksheet.
Note: Due to how
google-spreadsheet
works, there can be no blank rows, and the headers must be in row 1.