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.

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          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







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit
                              Intake FormsLegalMobile App
                              Form DesignerHRMobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsEncrypted Forms

                              Secure Forms

                              WCAG

                                      Create. Review. Publish.

                                      Write, edit, collaborate on, and publish documents to different content management platforms.

                                      Get Started Now






                                                        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

                                                              Use cases

                                                              Make the most of Zoho Desk with the use cases.

                                                               
                                                                

                                                              eBooks

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

                                                               
                                                                

                                                              Videos

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

                                                               
                                                                

                                                              Webinar

                                                              Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                               
                                                                
                                                              • Desk Community Learning Series


                                                              • Meetups


                                                              • Ask the Experts


                                                              • Kbase


                                                              • Resources


                                                              • Glossary


                                                              • Desk Marketplace


                                                              • MVP Corner

                                                                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 Demo

                                                                                                  Get a personalized demo or POC

                                                                                                  REGISTER NOW


                                                                                                    Design. Discuss. Deliver.

                                                                                                    Create visually engaging stories with Zoho Show.

                                                                                                    Get Started Now









                                                                                                                          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