Integrations

Dynamic fields from Google Sheets in Kommo

Sync custom fields with Google Sheets

Features

Field synchronization
Updating Values
Automatic synchronization
Mass changes

Installation and setup guide

Detailed guide for working with widget "Dynamic fields from Google Sheets in Kommo"

Widget setup

ℹ️If access to the table is disabled, then for the widget to work correctly, you must provide access to your Google service account [email protected]

How to use the widget

Add fields from the table, in our case these are Brand and Model

Important: Field names must be unique, i.e. in a lead or in a company or in a contact there should be only one field called Brand and one field called Model. If the lead has 2 fields with the same name, then the widget will not be able to find the field you need, similarly, if the lead has a field with the name Brand and the company/contact has a field with the same name, then the widget will not be able to find the field you need.

Important: In the access settings you need to specify that everyone who has a link can edit or give access to our [email protected]

When you click on the Brand field, hints for car brands will appear or you can start entering the brand in the field

After selecting a brand, click on the Model field and the models of the selected brand will appear

Autoloading fields

After preparing the table with the data:

1. Go to "Extensions" -> "Apps Script"

2. Paste the following code into the editor:

function createTrigger() {

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();


var triggers = ScriptApp.getProjectTriggers();


for (var i = 0; i < triggers.length; i++) {

if (triggers[i].getHandlerFunction() === 'onEdit') {

return;

}

}


ScriptApp.newTrigger('onEdit')

.forSpreadsheet(spreadsheet)

.onEdit()

.create();

}


function onEdit(e) {

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();


// Получаем активный лист (тот, где произошло изменение)

var activeSheet = e.source.getActiveSheet();


// Получаем ID листа (gid)

var sheetId = activeSheet.getSheetId();


// Получаем базовый URL таблицы

var baseUrl = spreadsheet.getUrl();


// Формируем полный URL с gid параметром

var fullUrl = baseUrl + "?gid=" + sheetId + "#gid=" + sheetId;


var url = "https://sp1-nova.ru/api/gt-cache-update/";


var payload = {

url: fullUrl, // Теперь отправляем полный URL с gid

subdomain: "subdomain"

};


var options = {

method: "post",

contentType: "application/x-www-form-urlencoded",

payload: payload,

muteHttpExceptions: true

};


try {

var response = UrlFetchApp.fetch(url, options);

Logger.log("Лист: " + activeSheet.getName() + " (gid: " + sheetId + ")");

Logger.log("Отправленный URL: " + fullUrl);

Logger.log("Код ответа: " + response.getResponseCode());

Logger.log("Тело ответа: " + response.getContentText());

} catch (error) {

Logger.log("Ошибка запроса: " + error.toString());

}

}

3. Instead of subdomain you need to write your own subdomain without .kommo.ru.

4. Next, click on “Save”.

5. Select the createTrigger function and click Run, granting all permissions.

6. Click on "Run".

Now, when you change a table, the data is automatically loaded into Kommo.