How to auto populate field in InfoPath based on another field?

How to Auto Populate Field in InfoPath?

No comments

Loading

In this “How to auto populate field in InfoPath” blog, I will share how to auto-populate the field in InfoPath based on another field. Let’s say I have a “Defect Tracking” custom list that has two columns “DefectID” and “Defect Details”. Now, the requirement is – in the InfoPath form there will be a textbox to enter the “Defect ID” and in another textbox “Defect Details” should be displayed which should filter the data from the “Defects Tracking” list.

Demo: How to Auto Populate Field in InfoPath?

Here, I will focus on the below two points:

  • How to add a data connection to SharePoint List or Library in InfoPath Form.
  • How to query SharePoint list items using the Infopath data query.

 

Filter SharePoint List in InfoPath Form
Filter SharePoint List in Infopath Form

From the above list, if the user enters the defect id in the form, then the corresponding defect details should display as a result in another textbox in the form.

Now, let’s start with how to implement it. Here, for this requirement, we need to use the InfoPath data technique.

How to auto populate field in InfoPath based on another field (InfoPath Forms)?

Below is the step-by-step process of how to auto-populate fields in InfoPath form based on another field:

Step1: Create a secondary data connection to the custom list “Defects Tracking” – InfoPath query data from SharePoint list

Click on the Manage Data Connection from the right side Fields panel.

Click on the “Add” button in the “Data Connections” wizard.

Create Secondary Data Connection in InfoPath Form
Create Secondary Data Connection in InfoPath Form

Then on the next screen, you will get an option as,

Create a new connection to:

  • Submit data – This is used to submit the InfoPath form data to the SharePoint list.
  • Receive data – This is used to read the data from the SharePoint list (by default, this will be selected).
Create Secondary Data Connection in InfoPath Form - Receive Data From SharePoint list
Create Secondary Data Connection in InfoPath Form – Receive Data From SharePoint list

As we want to display the data from the SharePoint list, we will go with the “Recieve” connection.

In the next screen, you will see “Select the source of your data”, select as SharePoint library or list.

Create Secondary Data Connection in InfoPath Form - SharePoint List or Library
Create Secondary Data Connection in InfoPath Form – SharePoint List or Library

Click on the Next button, you will see the “SharePoint site details” screen.

Enter your SharePoint site URL in the “Enter the location of the SharePoint site” box.

Example:

http://servername:siteport/ or http://server/site
Create Secondary Data Connection in InfoPath Form - SharePoint Site Details
Create Secondary Data Connection in InfoPath Form – SharePoint Site Details

Then, in the next screen you will see the below message to select the list or library:

The SharePoint site that you selected has the following lists and libraries you can use as your data connection.

From the available lists or libraries, select your list.

Click on the Next button.

Select the list of columns you want to display from the “The SharePoint list has the following fields that you can select from.” screen.

Click on the Next ->Next->Finish button.

Summary about the above receive data connection:

Create a secondary data connection to your “Defects Tracking” list and while creating the data connection select “Receive data” from the SharePoint list. Then select all your relevant columns like Defect ID, Defect Details, and so on. Now the secondary data connection is ready.

Create two textbox columns, one to pass the input and another one to display the result based on the input pass in the first text box (Defect ID), something like below:

  • SearchDefectByID
  • Defect Details

Step 2: query SharePoint list items using the Infopath data query – InfoPath query data from SharePoint list

Select the “Defect Details” text box in the form.

Step3:

Click on the Default value Fx button.

Step4:

Click on the insert field or Group

Step5:

Select your secondary data connection from the data connection list which you just created.

Step6:

Select the “Defect Details” from the Data Fields section

Step6:

Click on the filter button

Step7:

In the filter add select DefectID (from list secondary data connection) -eq "SearchDefectByID(from the form textbox - where you will enter that textbox).

Click 5 times OK, one after another.

Finally, the filter should look like the below:

Defect_x0020_Details[DefectID = SearchDefectByID]

Demo screenshot:

Display infopath filed based on the other field
Display InfoPath filed based on the other field

Output – preview or runtime:

Filter SharePoint list items from Infopath form
Filter SharePoint list items from the Infopath form

Now, we can see that based on the value entered in the “SearchDefectByID” textbox, the corresponding defect details are displayed in the “Defect Details” textbox which is coming from SharePoint’s “Defects Tracking” list.

Real-Time Use Cases for Auto Populating Fields in InfoPath

1. Employee Onboarding Forms

Scenario: When a new employee is onboarded, various forms need to be filled out, such as personal information, department details, and manager information. Use Case: Automatically populate the manager’s name and department details when the employee’s name is entered. Benefit: Saves time and ensures accuracy by reducing manual data entry.

2. Customer Service Requests

Scenario: A customer service representative needs to fill out a service request form when a customer calls in. Use Case: Automatically populate customer information such as address, phone number, and account details based on the customer ID entered. Benefit: Enhances efficiency and reduces the risk of errors, improving customer service experience.

3. Purchase Order Forms

Scenario: Employees need to create purchase orders for procuring goods and services. Use Case: Automatically fill in supplier information, item details, and pricing when an item code is entered. Benefit: Streamlines the procurement process and ensures consistent data entry.

4. Expense Report Forms

Scenario: Employees submit expense reports for reimbursement. Use Case: Automatically populate fields such as employee name, department, and manager’s approval based on the employee ID. Benefit: Simplifies the expense submission process and reduces the likelihood of errors.

5. Project Management Forms

Scenario: Project managers need to fill out project status reports. Use Case: Auto-populate project details like project name, start date, end date, and team members when the project ID is entered. Benefit: Saves time and ensures that project information is consistently entered across reports.

6. Leave Request Forms

Scenario: Employees request time off using a leave request form. Use Case: Automatically populate fields such as employee name, department, leave balance, and manager information based on the employee ID. Benefit: Makes the leave request process quicker and more accurate.

7. Incident Report Forms

Scenario: Employees need to report workplace incidents or safety issues. Use Case: Auto-fill fields like incident location, date, and employee details based on the incident ID or employee ID. Benefit: Improves the speed and accuracy of incident reporting, aiding in faster response and resolution.

8. Survey Forms

Scenario: Conducting internal surveys among employees or external surveys among customers. Use Case: Automatically fill in demographic information such as age, gender, and location based on the respondent ID. Benefit: Reduces the effort required by respondents to fill out the survey, increasing response rates.

9. Membership Application Forms

Scenario: New members applying for membership in an organization. Use Case: Auto-populate membership tier benefits, fees, and contact information based on the membership type selected. Benefit: Streamlines the application process and ensures accurate information is provided to applicants.

10. Travel Request Forms

Scenario: Employees submit travel requests for business trips. Use Case: Automatically fill in travel policy details, preferred vendors, and approval workflows based on the employee’s role and travel destination. Benefit: Simplifies travel request submissions and ensures compliance with company travel policies.

These use cases illustrate the versatility and efficiency gains that can be achieved by using auto-population features in InfoPath forms.

Summary: Auto populate Field in InfoPath Dynamically

Thus, in this blog, we have learned about how to filter the SharePoint list items using the secondary data connection data query and dynamically display the result in one textbox based on the value entered in another textbox. A few key points are:

  • How to add a data connection to SharePoint List or Library in InfoPath Form.
  • How to query SharePoint list items using the InfoPath data query.

See Also: InfoPath Forms Tutorial

You may also like the below InfoPath forms tutorials:

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment