// This module is included in the following assemblies:
// as_connecting-to-google-sheets.adoc

[id='add-google-sheets-connection-update-sheet-values_{context}']
= Updating data in a sheet

In an integration, you can update data in a spreadsheet
in the middle of a flow or to finish a simple integration.
To do this, add a Google Sheets connection to the middle of a flow
or as a simple integration's finish connection.

.Prerequisites
* You created a Google Sheets connection that is authorized to access the 
Google spreadsheet that you want to update.
* You have access to the spreadsheet ID for the spreadsheet that you want
to update.  
* You are creating or editing a flow and {prodname} is prompting you
to add to the integration. Or, {prodname} is prompting you to choose a finish connection. 

.Procedure
. On the *Add to Integration* page, click the plus sign where you 
want to add the connection. Skip this step if {prodname} is
prompting you to choose the finish connection. 
. Click a Google Sheets connection that is authorized to access
the spreadsheet that you want to update.
. On the *Choose an action* page, select *Update sheet values*.
. To configure the *Update sheet values* action:
+
.. In the *SpreadsheetId* field, do one of the following: 
+
* Enter the ID of the spreadsheet that you want to update. 
* Leave the field blank. In this case, after you add this connection 
to the flow, you must add a data mapper step
before this connection. In the data mapper step, map the spreadsheet ID from 
a previous connection to this connection. The previous connection must 
access the spreadsheet that you want to update in this connection.

.. In the *Range* field, use Google A1 notation to specify the spreadsheet
cells that you want to update. Specify the start and end coordinates, 
for example, `A1:D4` updates the first 4 columns in the first 4 rows in
the first sheet in the spreadsheet. 
+
The default is `A:A`, which updates the first column in the first sheet 
in the spreadsheet. 

.. In the *Major dimension* field, accept *Rows*, which is the default, or
select *Columns*. *Rows* configures the action to use row objects to update 
the sheet. Each row object contains a value for each column that you want to update.  
*Columns* configures the action to use column objects to update the sheet. 
Each column object contains a value for each row that you want to update.  

.. In the *Value input option* field, indicate how you want Google sheets
to interpret the data that it receives for updating the sheet. 
*Unspecified*, which is the default, enables Google Sheets to automatically 
convert data that it recognizes. For example, if the input data is a date, then 
Google Sheets formats it as a date. If the input data is a decimal, then 
Google Sheets formats it as a decimal. 
+
* *Unspecified* defaults to the Google Sheets API setting, 
which defaults to *User entered*.
* *Raw* causes Google Sheets to insert the input data as is.
* *User entered* enables automatic conversion of recognizable data. 

.. Click *Next* to add the connection to the flow.
The connection appears in the integration visualization in the
location where you added it.
. If you want to add any other connections to the flow, add 
them now and then return to these instructions. 
. After the flow has all desired connections, 
in the integration visualization, click the plus sign that is
just before the Google Sheets connection that updates sheet values.
. Click the *Data Mapper* card to add a data mapping step to 
the flow. 

. In the data mapper: 

.. If you did not specify the spreadsheet ID when you configured the 
*Update sheet values* action, then map a source `spreadsheetId` 
to the target `spreadsheetId`.

.. Specify the data that you want to use to update the sheet by 
mapping fields from a source step to the target spreadsheet. For example, 
you might map fields from another spreadsheet or from a database. 
+
If you need to, you can edit the Google Sheets connection that updates
sheet values and change the settings for *Range* or *Major dimension*. 
Changing these settings causes the data mapper to display different 
target fields according to your changes. 

.. In the upper right, click *Done* to add the data mapper step.
