Prefill content in a form based on another form

Prefill content in a form based on another form

Requirement

When one form is submitted with data, users are redirected to another form with pre-filled data from the previous form.

Use Case

An order management app contains two forms: one to store suppliers' details, and the other to store the details of the products supplied by the suppliers. When an admin enters the supplier's details in the Suppliers form and submits it, they are instantly redirected to the Products form with the Supplier field pre-filled.

See how it works

Steps to follow

1. Create two forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Suppliers
Suppliers
Single Line
Supplier Name
Supplier_Name
Products
Products
Single Line
Product Name
Supplier_Name
Single Line
Supplier
Vendor
 
2. Create a workflow with the following details:

The workflow is to be triggered when the Suppliers form is successfully submitted, so we are selecting the Form Event as "Successful form submission."
 
3. Click Add New Action and select Deluge Script.
 
4. Save the following Deluge snippet in the Deluge editor:
  1. openUrl("#Form:Products?Supplier=" + input.Supplier_Name,"same window");
The snippet uses the openURL deluge task to redirect users to the Products form on submission of the Suppliers form. It passes the value of the Supplier Name field in the Suppliers form to the Supplier field in the Products form.
 

See how it works

Points to note

  • This tutorial demonstrates the use case with a Single Line field type ( Supplier Name in the Products form). The same snippet would also work for the following field types:
    • Email
    • Phone
    • Multi Line
    • Rich Text
    • Formula
  • The following table specifies the required Deluge snippet for other field types:
Field type
Deluge snippet
Name and Address
Since these are composite fields, we have to pass the required sub field's name in the snippet in the following format:
  • <Name_field>.prefix
  • <Name_field>.first_name
  • <Name_field>.last_name
  • <Name_field>.suffix
  • <Address_field>.address_line_1
  • <Address_field>.address_line_2
  • <Address_field>.district_city
  • <Address_field>.state_province
  • <Address_field>.postal_Code
  • <Address_field>.country 
If more than one Name field is present in the form, the link names of the subsequent name sub fields will be modified by a number starting from 1. So, if we take the example of the subfield <field>.prefix, the link name of the first such field will be <field>.prefix, the link name of the second such field will be <field>.prefix1, the link name of the third such field will be <field>.prefix2, and so on. The same applies to Address sub fields.
 
If we want to pass a value to the first_name field, the D eluge snippet would look like:
  1. openUrl("#Form:Products?Name.first_name=" + input.Supplier_Name,"same window");
Lookup
Lookup fields are mapped to the related form through the ID of the selected field's record. Learn more.

Sample snippet:
  1. openUrl("#Form:Products?<Lookup_field>=" + input.ID,"same window");
Date and Time
Values being passed to a Date or a Time field can only be passed from another Date or Time field respectively.

Sample snippet:
  1. openUrl("#Form:Products?Order_Date=" + input.Supply_Date,"same window");
Drop Down, Radio, Multi Select, Checkbox
Only one of the existing pre-defined choices can be passed as a value.
Decision Box
One of the boolean values ( True or False ) can be passed as a value. The value True checks the box, and the value False unchecks it.
Currency, Decimal, Percent, Number
Only numerical values can be passed.
Add Notes
The passed value overwrites the existing notes on the form.
All other fields
This tutorial does not apply to all the other field types.