.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Auto-Fill textbox in InfoPath

Posted By:Jean Paul       Posted Date: September 29, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we can explore how to Auto-Fill a textbox in InfoPath form within SharePoint.
 

In this article we can explore how to Auto-Fill a textbox in InfoPath form within SharePoint 2010.

What is the Scenario?

Following is our Customer list with Code & Name.

clip_image002

Following is our Product list which has lookup to Customer Code.

clip_image004

On selection of the Customer Code dropdown list, we need to auto-fill the Customer Name text box.

clip_image005

clip_image007

In typical ASP.NET Forms we can use JavaScript to attain this functionality. But InfoPath web part enabled pages seldom works with JavaScript.

Solution

Please follow the steps below to attain the solution.

Step 1: Create Lists

Create the Customer list with 2 columns:

1. Code as Text

2. Name as Text

Create the Product list with 3 columns:

1. Product Code as Text

2. Customer Code as Lookup (connecting to Customer > Code)

3. Customer Name as Text

Step 2: Create InfoPath form

Open SharePoint InfoPath Designer 2010 from your start menu.

clip_image009

In the Initial Screen choose the SharePoint List & Click the Design Form button.

clip_image011

You will get the following wizard. Enter your site url & click Next button to continue.

(Please use only site url & not the list url. Enter Credentials if prompted)

clip_image013

In the next page choose the Customize option & select the Product list. Click Next button continue.

clip_image015

Click the Finish button.

clip_image017

You will get the following screen.

clip_image019

Step 3: Create Data Connection

On change of Customer Code drop down, we need to use the Code to search in Customer list & bring the Name field. For this, we need a Data Connection.

Choose the Data tab and click on Data Connections button.

clip_image021

In the appearing dialog box enter click the Add button.

clip_image023

Choose the Receive data option & click Next button.

clip_image025

In the next page choose the SharePoint list option.

clip_image027

In the next page leave the url of the site as it is.

clip_image029

In the next page choose the Customer list as the source.

clip_image031

In the next page select the Code and Name properties.

clip_image033

Click the Next button & Enter the name as CustomerDS for the data source.

clip_image035

We are now ready with our Data Source to query against.

Step 4: Modify form

We need to modify the Customer Name textbox. Right click on it & choose the Textbox Properties menu. You will get the following dialog.

clip_image037

Choose the Formula Editor which is the highlighted button above. In the appearing dialog, choose the Insert Field or Group button.

clip_image038

In the appearing dialog box, choose the Show advanced view link.

clip_image040

Now you will be able to select the CustomerDS data source. Expand the Data fields below & choose the Nameproperty as shown below. (Do not close the dialog)

clip_image042

Click the Filter Data button to enter our filter condition. In the appearing dialog box, click the Add button to add the filter. Choose the ID property against Select a field or group.

clip_image044

You will get the following dialog box.

clip_image045

Choose the Main data source and select the Customer Code property. Click the OK button. The filter condition looks like below.

clip_image046

You might be wondering why we are comparing ID property against Customer Code:

ยท In the background the Customer ID is stored & hence ID comparison is needed.

Close all the dialog boxes clicking OK button & the Properties dialog box looks like below.

clip_image047

Click the OK button to close the dialog box.

clip_image048

The Value says to take the Name property when ID equals to Customer Code

Step 5: Save & Publish

Save the form & Click on the Publish button.

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend