FAQ - Form Fields


General
Formula field
Picklist field
Date field

 


General

  1. How do I define form fields in script mode?
  2. Is there any naming conventions to be followed while defining form fields?
  3. What are the different types of form fields supported in Zoho Creator?
  4. How do I rename form fields in script mode?
  5. Can I delete a form field that contains data ? If so, how?
  6. Why is default value and tooltip not generated for some fields?
  7. Is there a way to configure a hidden field so that only the owner would be able to view/edit it?
  8. Is it possible to hide/display a field based on a condition?
  9. Sometimes, my requirement is such that combination of a field has to be unique. For example. Name of person and date of birth combination has to be unique. Is it possible to set that in GUI or script?

Formula Field

  1. I have a form with a formula field. I have also created a view for it and it has some data. I modify the formula field. But I am unable to view the table for sometime. Why is it so?

  2. Can one formula field be used in another formula in the same form?
  3. I'm trying to create a database for order entry. I want to have each order stamped with the time that it was submitted at. How can I go about doing that with ZOHO creator?

Picklist Field

  1. Can I import picklist from another form?
  2. Can I set a picklist to display only selected records in a different table?
  3. How can I create a dynamically populated drop down menu (single pick list). For example if I need Country and State to be captured in a form, how do I populate the right set of States when a Country is selected?

Date Field

  1. How can I calculate a date from another date field?

  2. If I want to know the difference between two dates, how can I do it?

 

General

 

1. How do I define form fields in deluge?

 

The fields in a form define the individual properties of the specific kind of information. A form field is also referred in two ways.

where,

Name, Age, Qualification -  label names

"Enter Age:" , "Educational Qualification"  -  display names

 

 

Note: If no type is specified, it is assumed to be of type text field.  e.g. Name

 

2. Is there any naming conventions to be followed while defining form fields?

 

A fieldname should be alphanumeric and can contain underscore.

 

3. What are the different types of form fields supported in Zoho Creator?

 

Refer Form field - Types to learn about the lists all the field types supported by zoho creator, its description and data type.

 

4. How do I rename form fields in script mode?

 

Renaming a field is a safe operation and would not affect the data in anyway.

form add_employee
{
    displayname = "Add Employee"  
     
     Name
     
     Age
     (
         displayname = "Enter Age: " "Enter Employee Age: "
         type = number        
     )
     Date_Of_Birth
     (
         displayname = "Date Of Birth"
         type = date
     )
     Qualification
     (
         displayname =  "Enter Qualification" "Enter Educational Qualification"
         type = number        
     )
}

The label name can be renamed by using the following syntax.

form add_employee
{
    displayname = "Add Employee"  
    
    Name as EmpName
     
    Age as EmpAge
    (
        displayname =  "Enter Age:"
        type = number        
    )
    Date_Of_Birth
    (
      displayname = "Date Of Birth"
      type = date
    )
    Qualification as EmpQualification
    (
        displayname =  "Educational Qualification"                            
        type = number        
    )   
}

5. Can I delete a form field that contains data ? If so, how?

 

When you delete a field, all the data corresponding to the field also gets deleted and it cannot be recovered. If no data is present, a field can be deleted by just removing the field definition from the text area and saving the script. If data is present, Zoho Creator will issue a error message that it is not possible to delete the field with the data present.

 

See a sample error message below:

 



To delete the field in such cases, you have to explicitly use the delete keyword.

 

form add_employee
{
    displayname = "Add Employee"  
    Name    
    delete Age
    Date_Of_Birth
    (
      displayname = "Date Of Birth"
      type = date
    ) 
    Qualification
    (
        displayname =   "Enter Educational Qualification"
       type = number        
   )
}

 

or just add a delete keyword before the field definition and save the script


form add_employee
{
    displayname = "Add Employee"  
    Name     
    
    delete Age
    (
        displayname = "Enter Employee Age: "
        type = number        
    )
    Date_Of_Birth
    (
      displayname = "Date Of Birth"
      type = date
    )
    Qualification
    (
        displayname =   "Enter Educational Qualification"
        type = number        
   )
}

 

6. Why is default value and tooltip not generated for some fields?


The script mode does not generate all the properties of a field. Only the properties modified by the user will be generated back and properties still having the default values would not get generated. e.g. For a text filed, the maxchar property will not be generated if it has not been modified by the user.

 

7. Is there a way to configure a hidden field so that only the owner would be able to view/edit it?

 

Yes, you can create a hidden field by having the "Hide this field to others" box checked, as shown in the screen-shot below. Selecting this option will make this field accessible only to the author/owner of the application.

 

 

 

8. Is it possible to hide/display a field based on a condition?

 

It is possible to do it in script mode using the Hide and Show deluge keywords. Refer the topic, Client side functions - Hide and Show for more information.

 

 

9. Sometimes, my requirement is such that combination of a field has to be unique. For example. Name of person and date of birth combination has to be unique. Is it possible to set that in GUI or script ?

 

It is possible to do it in script mode by writing an on submit script for the form. The "on submit" script gets executed before the data is persisted. In the following code, the "on submit" script is written to find if there are rows that have the same name and data of birth and cancels the submit action if there are any rows matching the criteria.


  
form user_info
{
    name
    (
        type = text
    )

    dob
    (
        type = date
    )

    on submit
   {
         if (count(user_info[(name == input.name && dob == input.dob)]) > 0)
        {
             cancel submit;
        }
    }
} 

 

 

Formula field

 

 

1. I have a form with a formula field. I have also created a view for it and it has some data. I modify the formula field. But I am unable to view the table for sometime. Why is it so ?


Whenever a formula is modified, the formula filed value will be recalculated for all the rows. You will not be able to see the view until this recalculation is completed.

 

2. Can one formula field be used in another formula in the same form ?


No, using one formula field in another formula is currently not supported.

 

3. I'm trying to create a database for order entry. I want to have each order stamped with the time that it was submitted at. How can I go about doing that with ZOHO creator?

 

You can record the time of the entry of a record by using a formula field with it's value set to zoho.currentime. This will automatically populate the exact time a particular record is persisted in the database. Here's how you can do it using the Deluge script:

 

 
Time_Stamp
  (
  type = formula
  value = zoho.currenttime
  )



In the UI mode, create a field with formula as it's type and just type zoho.currenttime as the value for the field in order to enable a timestamp.

 

Picklist Field

 

 

1. Can I import a picklist field from form A to form B?

 

You cannot import a picklist field from one form to another form. You can only import a textfield as a picklist in another form. (i.e) you can import a textfield in Form A as a picklist in Form B.

 

2. Can I set a picklist to display only selected records in a different table?

 

Yes, you can set a picklist to display only selected records in a different table. Refer Criteria in Import Picklist Data, for more information.

 

3. How can I create a dynamically populated drop down menu (single pick list). For example if I need Country and State to be captured in a form, how do I populate the right set of States when a Country is selected?

 

Yes, you can dynamically populate single picklist. Refer the topic, Add to picklist dynamically for more information. For your example, once you obtain the country and their corresponding state information, this is what you need to do:

4. How to make a field conditionally mandatory? I have two fields (Address and City) which are not considered mandatory unless another filed, Amount, is greater than 100. So if Amount is greater than 100, how can I assure that Address and City have values in them?

 

Yes, you can do this by adding the following code in the on submit function. In the following code, if Amount is greater than 100 and if Address/City have no values, the entry will not be sumitted.

 

  
on submit 
{
if ((input.Amount > 100) && ((input.Address == "") || (input.City == "")))
{
alert "enter Address/City";
cancel submit;
}
}


 

Date Field

 

1. How can I calculate a date from another date field?

You can manipulate a date field by using the '+' (to add) and '-' (to subtract) operators. For example, if you would like to add 364 days to a particular date field, say Date1 and display it in another field, say ExpiryDate, this is how you would do it .


Sample Code:

 

date1
(
type = date
)

 

ExpiryDate
(
type = formula
value = (date1 + '364D')
)

 

 

'D' stands for the number of days, 'W' stands for the number of weeks. The other units of time supported are 'H' (hours), 'M' (minutes) and 'S' (seconds).

 

 

2. If I want to know the difference between two dates, how can I do it?

 

You can very well subtract one date from another. You will get the difference in millisecond. You have to divide it accordingly to convert it to hours, days or weeks.

 

get difference in days = (date2 - date1) / (1000 * 60 * 60 * 24)

 

If you have the fields date2 and date1 of type date in your form, you can directly use the above expression in a formula field