If any value is a Google Spreadsheet is updated, this value can be sent to another software such as HubSpot CRM, etc. where it will be updated automatically.
Open Google Spreadsheet, click on menu Extensions. Then click on Apps Script to open Google Apps Script. It will open a code Editor named Code.gs. Add the following code with following editions,
1) At row 4, there is mentioned sheet1, replace it with worksheet name.
2) In row 6, there is mentioned columns to watch [1, 12]. It refers to columns from A to L, in spreadsheet, where A=1, B=2, C=3 etc.
3) In row number 21, there is mentioned total sheet columns with values, here is mentioned 12.
4) In row 38, there is mentioned URL_TO_SEND_DATA_AUTOMATICALLY where data needs to be sent automatically whenever a row is updated.
function editRow(e){
if(e.changeType=="EDIT" || e.changeType=="INSERT_ROW"){ //The type of change (EDIT, INSERT_ROW, INSERT_COLUMN, REMOVE_ROW, REMOVE_COLUMN, INSERT_GRID, REMOVE_GRID, FORMAT, or OTHER)
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); //get activated Spreadsheet
var sheet = spreadsheet.getSheetByName("sheet1"); //get sheet by sheet name
var headings = sheet.getDataRange().offset(0, 0, 1).getValues()[0]; //get heading
var columnsToWatch = [1, 12];
var row = sheet.getActiveRange().getRow();
var column = sheet.getActiveRange().getColumn();
var values = sheet.getSheetValues(
row, // starting row
1, // starting column
1, // number of rows
12 // number of columns
);
var payload ={}
for (i = 0; i < headings.length; i++) {
var name = headings[i];
var value = values[0][i];
payload[name] = value;
}
payload["row_number"] = row;
var options = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify(payload)
};
UrlFetchApp.fetch('URL_TO_SEND_DATA_AUTOMATICALLY', options);
}
}
After adding above Google Apps Script, in Apps Script left side menu, click on watch like icon named Triggers. Then click on Add Trigger. Add following values in different menus:
1) Choose which function to run : editRow
2) Choose which deployment should run : Head
3) Select event source : From spreadsheet
4) Select event type : On change
And then click on Save button.
After that click on Deploy and select New deployment. Now the Google Apps Script is ready to work.