Creator Help

Fetch data from a form and use it in another form

The following two examples demonstrate how to fetch data from a form and use it in another form. To do so, a relationship has to be established between the two forms. This is achieved by using Lookup fields.

Example 1

The sample application named Collection Variable, demonstrates the usage of the Fetch Records task to fetch records from a Form and use it for calculation in another form. This application has two forms:

  • Form A - stores the Name and Salary of employees.
  • Form B - consists of a Lookup (Employee) field based on the Name field in Form A and Commission field to enter the commission to be paid for each employee. The Total field will be calculated by adding the Salary and the Commission. The Salary will be fetched from From A.

Note:

Script

In the On User Input block of Customer Field in Form B

if (input.Customer != null)
{
if (input.Commission != null)
{
dat = FormA [ID == input.Customer];
input.Total = (dat.Salary + input.Commission);
}
}

 

In the On User Input block of Commission Field in Form B

if (input.Commission != null)
{
dat = FormA [ID == input.Customer];
input.Total = (dat.Salary + input.Commission);
}

Script Explanation

dat = FormA[ID == input.Customer];

The records related to the above specified criteria is fetched from the Form A and stored in the collection variable dat.

input.Total=(dat.Salary + input.Commission);

The Salary field of fetched record is added to the input of the Commission field and the result is displayed in the Total field.

Example 2

The application “Copy Records” comprises of the following two forms – Leads and Clients. Leads form with fieldsName – Phone – Email to enter the Lead details. Clients form with fields Name – Phone – Email – Address to enter the Client details. When a lead becomes a client, the lead details are updated in the Client table. This is achieved by adding a custom action button to each record in the Leads view. Selecting the button will invoke a function to add the specific record to the clients form.

Deluge Script

1. Add a function to copy the record from the Leads form to the Clients form. The function copyRecord is added to the Script -> Functions tab. This function is invoked when you click on the Copy to Client custom action button.

void copyRecord(string Name, int Phone, string Email)
{
insert into Clients
[
Email = input.Email
Name = input.Name
Phone = input.Phone
Added_User = zoho.loginuser
]
}

2. Configure the above function as a custom action in the Leads view. Select Views ->Leads View ->Custom Actions and specify the name of the action as Copy to Clients and click on show action for each record. Specify the required values and click Done.

To install the application,

 Learn how to install the application to your account - click here.

Top