How can I fetch a value (for example, the salary assigned to an employee) from a form and use it in calculation in another form?

How can I fetch a value (for example, the salary assigned to an employee) from a form and use it in calculation in another form?

About the application

To fetch data from a form and use it in another form, a relationship has to be established between the two forms, using Lookup fields. The 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 has 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: To create relationships between forms using Lookup fields, refer the topic Creating relationship.

Deluge Script

To calculate Total value, On user input script is added to the Employee and the Commission field as given below. The script will be executed when an employee is selected or when the commission amount is entered.

Employee
(
type = picklist
values = FormA.Name
on user input
{
if (input.Employee != "-Select-")
{
if (input.Commission != null)
{
dat = FormA [Name == input.Employee];
input.Total = (dat.Salary + input.Commission);
}
}
}

)

Commission
(
type = USD
width = 20
on user input
{
if (input.Commission != null)
{
dat = FormA [Name == input.Employee];
input.Total = (dat.Salary + input.Commission);
}
}

)

To install the application,

  1. Download the script file (.ds file)
  2. Install the application to your account. Click here to learn how to install using the script file (.ds file)