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


Discover more from Global SharePoint

Subscribe to get the latest posts sent to your email.

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