Creating Relationship between Forms using Lookup
A Lookup field is used to create a relationship between two forms in Zoho Creator, within the same application or different applications. When you create a relationship, you tell Zoho Creator to link a record in one form to one or more records in another form. Refer the topic Forms -> Creating Relationship, t o learn more about adding Lookup fields and creating relationship between forms in Zoho Creator using Lookup fields.
Customizing the Display of a Lookup
You can customize the display of the lookup field by selecting the Advanced Display options as shown in the screen-shot given below. You will have an option to construct the display value using any separator between the fields that you choose.
For example, if FormA stores the name of an employee in two different fields - "First Name" and "Last Name", you can create a lookup to FormA to display the name field in the format First Name - Last Name. In live mode the lookup field will display the values in the specified format in the Form and View, as shown in the screen-shot given below.
Adding new entries to the Parent Form
Selecting the option "Allow users to add new entries in <FormName>" will add a link with the specified text to the right or the bottom of the lookup field. Users will be able to add new entries directly to the parent form by selecting this link.
In FormB, the lookup field "Name" will display the link to add new entries directly to the parent form (FormA), as shown in the screen-shot below.
The Parent form (FormA) is displayed from FormB, as shown in the screen-shot below.
The new entry is also updated in the lookup field in FormB, as shown in the screen-shot below.
Creating a link to parent records
You can create a link to the lookup field to view the parent record details.
To do this,
- Select the view of the form to which the lookup is added.
- Select Column Properties and click on the Link button that will be displayed for the lookup field, as shown in the screen-shot below. By default, the link button is disabled.
- Click Done to update the changes.When you access your application and view the data, the lookup field values will be linked to the parent form, as shown in the screen-shot below.
Creating a Bi-directional relationship
You can create a Bi-directional lookup to track the related items from both the Parent and Child form.
Steps to create a bi-directional lookup
- Select the option Enable bidirectional relationship in the Lookup dialog, as shown in the screen-shot given below.
- Select the field to be related in the current form from the drop-down list.
- Select the display type of the related field as a single-select or multi-select list and click Done to create the bi-directional relationship.
- A bi-directional relationship is created between the Employee and Department Forms, as shown in the screen-shot below. The Bi-directional field is the Email-id field in the Employee form.
- In the Employee Form, the field Department is a single-select lookup to the Department Form, as shown in the screen-shot below.
- The Email Id field in the Employee Form which is configured as the bi directional field of type multi select, is added to the Department form, as shown in the screen-shot below.
- In the above example, the lookup field (Department) is of type single-select and the bi-directional related field (Email Id) is of type multi-select. A one-to-many relationship is established between the Department and the Employee Forms. (i.e) one department can have many employees. The employee details can be managed from both the Employee and Department forms.
- If the lookup is of type single-select and the bi-directional related field is also of type "single-select", a one-to-one relationship is established. For example, in the Employee form, if Department is added as a single-select lookup with Employee email-id as a single-select related field, then a department can be assigned to only one employee. Assigning the same department to another employee, will remove the existing relationship.
- If the lookup is of type multi-select and the bi-directional related field is of type multi-select, a many-to-many relationship is established. For example, in the Employee form, if Department is a multi-select lookup with Employee email-id also as a multi select related field, one department can have many employees and each employee can belong to more than one department.
Setting Lookup Criteria
You can use the Set Criteria option in lookup fields to restrict the entries that will be displayed in the lookup field, based on a given criteria. Please refer this help topic for more information.