Section |
---|
Column |
---|
Let's take a look at how you can update existing values in a sheet. It’s another common scenario that can be used for a variety of tasks (e.g. limiting the number of submissions for a particular form or creating a sequentially increasing counter). We’ll use this sample Google Sheet to discuss. It has a row for each employee: Employee Id, Location and Extension. Info |
---|
First, it’s important to note that Google Sheets is not a transactional system like a database and results can be unpredictable if multiple users update the same Sheet at the same time. |
|
|
...
If you do not have an access token for your Google Account, perform this one time step.
Insert excerpt |
---|
| frevvo92:Obtain an Access Tokenfrevvo92: |
---|
| Obtain an Access Token |
---|
nopanel | true |
---|
|
Note |
---|
Escape the slash characters in your OAuth token with a backslash in the rule below like this: OAuth21\/\/<###...> |
Step 2: Add the Business Rule
...
- It’s triggered by clicking on the Update Google Sheet button.
- We setup headers and an update query using your access token and spreadsheet key (the long ID in the URL of the Google Sheet). In this example, the name of the Google Sheet tab is Locations. Change the wsname= parameter to the name of your Google Sheet tab if you named the tab something different.
- Add updateparams: we’re updating location and extension with new values.
- Run the update – perform an http.put() and eval the results.
Tip |
---|
The column name on a Google sheet must match the control name. The matching is case-insensitive and any spaces in the column name are ignored. A control named "FirstName" matches a column header "first name." However, references to Google Sheet columns in your rule must be lower case and cannot contain spaces. The correct reference for this example is "firstname." |
Note |
---|
Reserved characters in a URL need to be encoded. The example above uses the encodeURIComponent function in JavaScript for every parameter value and invoke the http function with the extra encode parameter set to false. |
...