How to create a custom calculated field

This article is for creating custom calculated fields for use in records and uses C# (C sharp).
If you want to learn how to create a calculated field to be used in your dashboard cards, read How to create a calculated field for an Insightly dashboard card instead.

Custom calculated fields allow you to create mathematical formulas using C# (C sharp). The formulas you can create and their resulting values are based on the data entered in your records.

These fields are read-only since their values come from your formulas. You can create simple formulas using IF statements to return the calculated values, but your statements cannot contain for loops, do while loops, or method declarations.

If you're not familiar with C# (C sharp) or any C programming language, you may want to get assistance from someone who is more familiar with coding.

You can create 20 calculated fields per object.

To save the calculated field, you must return a value and validate the formula.

To create the calculated field:

  1. Click the profile icon and click System Settings.
    _4a977cf23a58e5bb5b117caebb141e4d__Image_2018-11-27_at_3.11.22_PM.png
  2. Click Objects and Fields.
  3. Select the object you want to create the field for (you can create a custom calculated field for Contacts, Organizations, Opportunities, Leads, Projects, and Custom Objects).
  4. Select Object Fields from the Object Management menu.
  5. Click New Field. 
  6. Choose Calculated Field. 2018-11-28_15h03_53.png
  7. Complete the required fields: 
  • Field Label – Enter the name for your new field. For example, we are going to create a new field under Opportunities called “Revenue minus expenses (you won't be able to use the same field name twice)."
  • Field Name - The name will automatically fill after you've added your Field Label, but you can alter it if needed. Note: Field Names are followed by __c (two low dashes, then c).

8. Select the Field Type for the returned value. Your formula must return a value based on the field type you select. If you select a number for your field type, your formula must return a number. The same applies to a checkbox, date, date/time, percent, and text field.

9. Enter your formula in the Field formula. To help build the formula, click the Helpers button.

You can add values to the formula box by double-clicking or dragging any item from the Objects Fields or Functions list, typing directly in the field, or by copying and pasting a provided formula, such as the examples at the end of this article.

Under Object Fields, the different field types are sorted by type. For example, if you want to view the string fields, select String Fields.

The Functions list is also sorted by their function types, such as Boolean (True or False), DateTime, and Decimal. When typing your formula, Insightly also has a built-in IntelliSense that provides drop-down options to help complete your code.

To learn more about the functions, click any function and read the description.

Screen_Recording_2018-11-28_at_03.44.01.42_PM.gif

Calculated fields cannot use the results of another calculated field in the formula. All values in your formula must be from static fields.

10. Click Validate Formula to check your formula can compute. If Insightly cannot validate your formula, an error message will display above the formula field stating why.
11. Click Save Custom Field.

Sample Formulas

Below are some sample formulas to get you started. If you need help more help building fields, contact our sales team at sales@insight.ly.

Date_Calculated_Field.png

return DateTime.Now;

Number_Calculated_FIeld.png

return Record.Revenue__c - Record.Cost__c;

Text_Calculated_Field.png

return CurrentUser.FIRST_NAME + " " + CurrentUser.LAST_NAME;

 

Have more questions? Submit a request
Top