Auto populate a field based on the selection from a lookup dropdown

Auto populate a field based on the selection from a lookup dropdown

Requirement  

When a value is chosen from a lookup dropdown, related values are populated in the other fields of the same form.

Use Case  

An order management app contains a form to store order details. When the admin chooses the customer name from the dropdown, the customer details will be auto-populated. Similarly, when the admin chooses a product that is a lookup field in a subform, other related fields like Unit of measurement and Unit price will be auto-populated.

Steps to follow  

1. Create three forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Customers
Customers
Name
Customer Name
Customer_Name
Number
Customer ID
C_ID
Phone Number
Phone_number
P_No
Products
Products
Single Line
Product
Product
Currency
Price
Price
Single Line
Unit of measure
Unit_of_measure
Orders
Orders
Lookup
(Customers)
Customer Name
Customer_Name
Single Line
Customer ID
Customer_ID
Phone Number
Phone number
Phone_number
Subform
  • Lookup
    (Products)
  • Number
  • Currency
  • Number
  • Currency
Products
  • Products
  • Unit of measure
  • Unit Price
  • Quantity
  • Total
Products
  • Products
  • Unit of measure
  • Unit_Price
  • Quantity
  • Total
 
2. Create a workflow with the following details:


This workflow is to disable the fields of the Orders form that will be auto populated, hence we are selecting the Form Event as "Load of the form".
 
3. Click Add New Action and save the following deluge snippet in the deluge editor:
  1. disable Customer_ID;
  2. disable Phone_number; 

4. Create a workflow with the following details.

The workflow is to be triggered when a user inputs a value to the Customer Name field of the Orders form is successfully submitted, so we are selecting the Form Event as "User input of a field".

5. Click Add New Action.

6. Save the following Deluge snippet in the Deluge editor:
  1. if(Customer_Name != null)
  2. {
  3. // Fetch the record corresponding to the selected customer name from Customers form
  4.  related_record = Customers[ID == input.Customer_Name];

  5. // Update fields with the related values fetched from Customers form
  6.  input.Customer_ID = related_record.C_ID;
  7.  input.Phone_number = related_record.P_No;
  8. }

input.<lookup field> returns the ID of the parent form record that contains the selected value. So, the above snippet uses ID == input.Customer_Name as criteria to fetch the corresponding record from the Customers form.
 
7. Next, let's try populating subform fields based on a subform field. Create workflow with the following details.

The workflow is to be triggered when a user inputs a value for the Products subform field of the Orders form, so we are selecting the Form Event as "User input of a field".
 
8. Click Add New Action and s ave the following Deluge snippet in the Deluge editor:
  1. if(row.Products != null)
  2. {
  3. // Fetch the record corresponding to the selected product from Products form
  4. related_record = Products[ID = row.Products];

  5. // Update fields with the related values fetched from Customers form
  6.  row.Unit_of_measure=related_record.Unit_of_measure;
  7.  row.Unit_Price=related_record.Price;
  8. }

See how it works     


Points to note  

  • input.<LookupField> returns ID of the record in parent form. Similarly, to insert a value into a lookup field, set ID of the record in the parent form as value to the field.

    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION









                                      You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                          Manage your brands on social media

                                            Zoho Desk Resources

                                            • Desk Community Learning Series


                                            • Digest


                                            • Functions


                                            • Meetups


                                            • Kbase


                                            • Resources


                                            • Glossary


                                            • Desk Marketplace


                                            • MVP Corner


                                            • Word of the Day


                                              Zoho Marketing Automation

                                                Zoho Sheet Resources

                                                 

                                                    Zoho Forms Resources


                                                      Secure your business
                                                      communication with Zoho Mail


                                                      Mail on the move with
                                                      Zoho Mail mobile application

                                                        Stay on top of your schedule
                                                        at all times


                                                        Carry your calendar with you
                                                        Anytime, anywhere




                                                              Zoho Sign Resources

                                                                Sign, Paperless!

                                                                Sign and send business documents on the go!

                                                                Get Started Now




                                                                        Zoho TeamInbox Resources



                                                                                Zoho DataPrep Resources



                                                                                  Zoho DataPrep Demo

                                                                                  Get a personalized demo or POC

                                                                                  REGISTER NOW


                                                                                    Design. Discuss. Deliver.

                                                                                    Create visually engaging stories with Zoho Show.

                                                                                    Get Started Now









                                                                                                        • Related Articles

                                                                                                        • Dynamically Filter Lookup Options Based on Another Lookup Field's Selection

                                                                                                          Requirement Automate the creation of portal user accounts based on the email entered in the Zoho Creator form. Use Case Consider an IT asset management application on which an organization relies to register and monitor assets assigned to employees. ...
                                                                                                        • Auto-calculating values on a subform's field

                                                                                                          Requirement Perform statistical operations on the numerical fields in subforms for analysis. Use Case  In an order management application, there are two forms, Order and Product. The Product form lists all the products in the inventory and the Order ...
                                                                                                        • Autopopulate Zoho Creator field with Zoho People data

                                                                                                          Requirement Autopopulate Zoho Creator field with employee information stored in Zoho People. Use case Let's assume an organization named Zylker has a private library. The regular users must purchase a membership in order to access the library, ...
                                                                                                        • Understand Lookup Field

                                                                                                          Understand Lookup Field The lookup field enables you to create a relationship between forms. Using this relationship you will be able to lookup data from another form in the same application or from a form in a different application in your Zoho ...
                                                                                                        • Configure bidirectional lookup field

                                                                                                          To configure bidirectional lookup: Navigate to the form builder. Drag and drop the lookup field. The Lookup field window appears. Select the Form from which you need to fetch data. Select the Field . Click the toggle button to Enable bidirectional ...
                                                                                                          Wherever you are is as good as
                                                                                                          your workplace

                                                                                                            Resources

                                                                                                            Videos

                                                                                                            Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                            eBooks

                                                                                                            Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                            Webinars

                                                                                                            Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                            CRM Tips

                                                                                                            Make the most of Zoho CRM with these useful tips.



                                                                                                              Zoho Show Resources