Increment a counter, update Google sheets
@dylburger
code:
data:privatelast updated:4 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
increment_counter
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
}
6
this.checkpoint = $checkpoint + 1 || 1;

// Write the new value of checkpoint back to $checkpoint for the next workflow run
$checkpoint = this.checkpoint;
steps.
update_spreadsheet_values
Updates the values of the cells of the specified range, for the specified spreadsheet ID.
auth
(auths.google_sheets)
params
Range

The A1 notation of the values to update, including the sheet to update. For example: “Sheet1!A1:B2”

Sheet1!A1:A1
string ·params.range
Values

The array of new values to update the sheet with. Google Sheets requires an array of arrays here, representing the grid of values you'd like to update in your sheet (see the docs for more information).

[0]:
{{ [steps.increment_counter.checkpoint ] }}
array ·params.values
Spreadsheet ID

The ID of the spreadsheet to retrieve data from (found in the URL at docs.google.com/spreadsheets/d/{id})

 
string ·params.spreadsheetId
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
}
23
const data = {
  range: params.range,
  values: params.values,
  majorDimension: params.majorDimension,
}
const config = {
  method: "put",
  url: `https://sheets.googleapis.com/v4/spreadsheets/${params.spreadsheetId}/values/${params.range}`,
  params: {
    includeValuesInResponse: params.includeValuesInResponse,
    responseDateTimeRenderOption: params.responseDateTimeRenderOption,
    responseValueRenderOption: params.responseValueRenderOption,
    valueInputOption: params.valueInputOption || 'USER_ENTERED',
  },
  headers: {
    Authorization: `Bearer ${auths.google_sheets.oauth_access_token}`,
  },
  data,
}
return await require("@pipedreamhq/platform").axios(this, config)