THE «Fields Calculator» WIDGET USER MANUAL
In this manual you will learn how to:
  • Install and set up this widget in Kommo
  • Create a simple formula for numerics
  • Create a formula with non-numeric field values
  • Work with built-in functions and JavaScript
Widget installation
Go to your Kommo account > «Settings» > «Integrations».

Find this widget in the list or enter «Fields Calculator via Komanda F5» in the search bar.
Check the checkbox to accept Kommo's privacy policy and grant access to the account > «Install».
Now there is an additional item «Fields Calculator» in Kommo settings.

Create a simple formula for numerics
  1. Go to the widget settings.
  2. Click the «Add new formula» button, a formula editor window will appear.
  3. Enter a name for the formula, for example «5% discount».
  4. Enter the formula itself. You can use all math operators, brackets, fields from lead cards, companies, and contacts. To insert the field from Kommo into the formula, use the list of fields. Find the field you need and click on it, the field ID will be inserted where the cursor is in the formula editor.
  5. Choose the «Result field» where the result of calculations will be saved.
  6. Check if the formula works correctly. In the «Dependent fields» section on the right, enter any data and click the «Check» button. The result of calculation will appear in the «Formula Result» area.
  7. Save the formula and check the result in the real Kommo card.

Creating a formula with non-numeric field values
You can «assign» numeric values to non-numeric fields in Kommo.
Examples:
The «Delivery» toggle switch should add $20 to the lead sales value;
Each item in the «Services» list can be given its own price, which, when selected, will be added and summed up in the sales value field.
1. Fill out the catalog

  1. Go to the Field Calculator settings, «Catalog» tab.
  2. Click «Add new catalog».
  3. Enter a name, select the entity (lead, contact, or company) and select the field from which the values will be taken for calculation.
  4. Below set the values of the catalog, depending on the value selected in the field. In simple terms, put a price in front of each item. If it is a text field, add the text manually and give it a value. If any of the values should have no effect on the price, then put 0. You can also use negative numbers.
  5. Save the catalog.

2. Create formulas using catalogs

No different from a regular formula except for the type of a field. The word «.data» is added to the field .

  1. Go to Kommo «Settings» > «Fields Calculator».
  2. Click the «Add new formula» button, and a formula editor window will appear.
  3. Enter a name for your formula, e.g. «5% discount».
  4. Enter a formula, for example: «(lead.sale - lead.cf585310) * 0.95» . You can use all mathematical operators, brackets, fields from leads, companies, or contacts.
  5. To insert a field catalog into a formula, click on the blue icon to the right of the field. The icon shows that the numeric fields for the values to be used in the formula have been set for that field. This will insert «lead.cf585310.data» instead of «lead.cf585310». The formula will now use the numbers from that field's directory for the calculation, and the number itself will change depending on what is selected in the field.
  6. Save the formula and check the calculation results.

Working with built-in functions and JavaScript
The calculator has functions to work with variables from Kommo, for example: list of products, user properties, current date, currency rate, etc. The widget fully supports the use of the JavaScript language.
1. Save the sales value of all products in the lead field

Function used:
products = GETLEADCATALOG(lead.id, 7949);
array = MAP(products, function(product) {
return product['fields'][1014880]['value'] * product['quantity'];
});
ROUND(SUMARRAY(array),2)

Change the list ID - 7949 and the list field ID - 1014880 to your custom values.
2. Save the list of products in the lead field

Function used:
function JOIN (array) {
return array.join('; ')
}
products = GETLEADCATALOG(lead.id, 7949);
array = MAP(товары, function(product) {
return product['title'] + ' ' + product['quantity'] + ' pcs.';
});
JOIN(array)

Change catalog ID - 7949 to your custom value.
3. Change the color of the lead field in Kommo

Change the color of a particular field:
cssParamsGreen = {'background':'rgb(229, 255, 243)', 'padding-left': '5px','border-radius':'4px','border': '1px solid rgb(178, 225, 198)'};
ARRAYFORMULA(
CSS(SELECTOR(false, '.linked-form__field[data-id="43921"] .linked-form__field__value',true),cssParamsGreen)
)
false;

You can change the following: background, border, padding to your custom values and colors. data-id=«43921» - can be changed to your field ID.


Change the color of a particular field according to its value:

cssParamsGreen = {'background':'rgb(229, 255, 243)', 'padding-left': '5px','border-radius':'4px','border': '1px solid rgb(178, 225, 198)'};
cssParamsRed = {'background':'rgb(255, 244, 244)', 'padding-left': '5px','border-radius':'4px','border': '1px solid rgb(255, 192, 192)'};
ARRAYFORMULA(
IF(lead.cf43923>=1000,CSS(SELECTOR(false, '.linked-form__field[data-id="43923"] .linked-form__field__value',true),cssParamsGreen),CSS(SELECTOR(false, '.linked-form__field[data-id="43923"] .linked-form__field__value',true),cssParamsRed))
)
false;

Here you can also change the field background and borders settings. If lead.cf43923 >= 1000, change its color to cssParamsRed, otherwise cssParamsGreen. Change to your custom values.


Change the color of the lead field depending on the values of other field:

cssParamsGreen = {'background':'rgb(229, 255, 243)', 'padding-left': '5px','border-radius':'4px','border': '1px solid rgb(178, 225, 198)'};
cssParamsRed = {'background':'rgb(255, 244, 244)', 'padding-left': '5px','border-radius':'4px','border': '1px solid rgb(255, 192, 192)'};
cssParamsYellow = {'background':'rgb(240, 247, 154)', 'padding-left': '5px','border-radius':'4px','border': '1px solid rgb(255, 192, 192)'};
ARRAYFORMULA(
IF((lead.cf43929.value-10800)==DATEUNIX(DATEFORMAT(NOW(),'M.D.YYYY')),CSS(SELECTOR(false, '.linked-form__field[data-id="43931"] .linked-form__field__value',true),cssParamsYellow),IF(lead.cf43929.value>DATEUNIX(DATEFORMAT(NOW(),'M.D.YYYY')),CSS(SELECTOR(false, '.linked-form__field[data-id="43931"] .linked-form__field__value',true),cssParamsGreen),CSS(SELECTOR(false, '.linked-form__field[data-id="43931"] .linked-form__field__value',true),cssParamsRed)))
)
false;

If the field 43929 value is equal to the current date, the background color of the field 43931 changes into «yellow». If the value is bigger - the color will be green, if less - red. Change to your custom values or conditions.
Are you having troubles with the widget configuration? Complicated business processes in your company?
Request a professional setup from Komanda F5.
Full automation of your workflow on a turnkey basis, considering the specifics of your company.