ZohoCreator : Custom formula

Zoho Creator | August 16, 2006 | 2 min read

Creating custom formula is a powerful feature and it is a beginning to providing excel-like functions in Zoho Creator. Even the simplest of applications like a student marks database( given below as an example) or an expense tracker (to calculate the total expenses) requires custom fields that are calculated based on the values of other fields. They have to be created while defining the form and could be numeric, text, date or boolean.

* You can create calculated fields by selecting the field type as formula.

* All the types of form fields except multiple select fields can be used in formulas.
* The operators / functions that can be used in formulas can be found in the Deluge docs.
* The formulas will get recalculated when
  a. the formula is modified
  b. the values of the fields participating in the formula gets modified (when a record is updated).

Given below is a sample marks database application. The fields TotalMarks and AverageMarks are of type formula.


  application Student_marks_database
  {
     page Enter_marks
    {
      form Students_Mark_Sheet

      {
        Student_Name
        (
          type = text
        )
        English
        (
          type = number
          decimalplace = 2
        )
        Arts
        (
          type = number
          decimalplace = 2
        )
        TotalMarks
        (
          type = formula
          value = English + Arts
        )
         AverageMarks
        (
          type = formula
          value = (English + Arts) / 2
        )
      }
      list View_student_marks
      {
        Students_Mark_Sheet
      }
    }
  }

Please follow the following steps to create the sample application

* Login to Zoho Creator
* Click on Create Application
* Select Deluge script tab
* Copy & paste the code given below and save.

Your have now created a students marks database. You can now add some data and see the formula fields getting updated in the view.

Do send your comments / suggestions on this feature.