Autopopulate Form Data
A relationship is established to fetch data from a Form and use it in another Form using Lookup fields. To create relationships between Forms using Lookup fields, refer the topic Creating relationship. Once the relationship is created, the form data can be populated from one form to another. This is illustrated with the help of a sample application.
The sample application Service Request consist of three forms.
- Customer details - Holds the details of the customers.
- New Request - Used to enter a new service request from a customer. It consists of Customer Id as a lookup field from Customer details form and other fields to display the customer details and request details.When a Customer Id is selected from the list, the customer details like, Name, Mobile number and Email Address will be displayed from the Customer details Form.
To achieve the above requirement, we have to add On User Input script to the Customer ID field in the New Request form, as shown below.
temp = Customer [ID == input.Customer];
input.Name = temp.Name;
input.Email = temp.Email;
input.Mobile_Number = temp.Mobile_Number;
- The if condition checks whether the customer already exists.
- If the customer already exists,the record that satisfies the given criteria is fetched, and store it in a collection variable temp.
- The customer name is updated in the New Request form from the variable “temp”. Here, input.Name refers to the Customer name field in the New Request form and temp.Name is the customer name field fetched from the “Customer details” form.Similarly the other fields are populated as shown in the above code.