Solved

Using database fields in InfoPath

Posted on 2009-05-15
3
682 Views
Last Modified: 2012-05-07
I have an InfoPath form with a data connection to a Sharepoint list. One field (UserName) allows the user to select their name from a Sharepoint list field. I have a few other text fields.and would like their default values to pull their data from the Sharepoint list record selected. For example, the user's address, phone number etc. The user could then modify their contact information as needed.

How do you have the text fields reference the values in the SP list of the record selected in the UserName field?
0
Comment
Question by:Omer Maor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Greg Burns earned 250 total points
ID: 24406015
I did something similar to this once. I had a dropdown list that pulled a list of names from a SharePoint site; when a user selected a name, that person's phone number and email were displayed in two other fields. Here is how I did it:
Add fields to the form:
  1. Add a combo box. This will contain the dynamic list of names to be used. Give this control a meaningful name, as it will be referenced by other fields on the form. I named mine "NameOfRequestor"
  2. Add two text boxes and make them read only. these will display the Phone and Email addresses. Since they are lookup values, I didn't want the user to change them. I named these fields "RequestorPhone" and "RequestorEmail".
Add a data connection:
  1. Go to Data Sources and add a new connection to Receive Data.
  2. Select SharePoint Library or List
  3. Enter the URL of the site you're receiving data from.
  4. Select the list / library.
  5. Specify the columns you want to include in your resultset (In my case, it was Full Name, Phone, and Email)
  6. You can optionally choose to save a copy of the downloaded results in the form template, so that it will contain a snapshot of list items that will be available when the form is filled out offline.
  7. Provide a name for the data connection (I named mine "Requestors") and click Finish.

Click on Properties to Bind the Data Connection to the Combo Box.
  1. Under Llist box entries, select "Look up values from an external source"
  2. Select the data source you created above.
  3. In the "Entries" field, click the Browse button and drill down to MyFields-->dataFields-->(Your data connection). Click OK.
  4. The "Value" and "Display Name" fields will suggest a field to be used, If it is not the right one, browse to the correct fields. In my case it was @Full_Name.
Set up a Rule to update other fields when this field is updated.
  1. In the Combo Box properties, click the "Rules" button. Add a new rule.
  2. Do not set a condition (this rule always applies).
  3. Add an action to update the RequestorPhone text box.
  • Action: "Set a field's value".
  • Field: This part is a little tricky. You want to update the text box, so be sure the "Data source" is set to "Main". Drill down to the "RequestorPhone " field and click OK.
  • Value: Click the formula button.
    • Click the Insert Field or Group button and select the Requestors Data source you added above.
    • Drill down to the "MyFields-->dataFields-->Requestors" and select the field for "Business_Phone" (this is the name of the field in my SharePoint list).
    • Click the Filter Data button.
      • Add a filter for when "Full_Name" "is equal to" and in the criteria field, click "Select Field or Group". In the "Main" data source, select the "NameOfRequestor" combo box.
      • Click OK.
      • Click OK.
    • The formula should read something like "@Business_Phone[@Full_Name = NameOfRequestor]".
    • Which translates to "Show me the [Business Phone] value from my data set where the [Full Name] value matches whatever value is in the Combo Box [NameOfRequestor].
  • You're not done!

    Now keep adding other actions and do the same thing for all other associated fields you want to update whenever the Combo Box is updated.   They will all trigger at once and display associated information.
hope that helps!
0
 

Author Comment

by:Omer Maor
ID: 24423487
Thanks for such a tremendously detailed response. I'll check it out and let you know how it went.
Sam
0
 

Author Closing Comment

by:Omer Maor
ID: 31582094
Perfect - worked like a charm. Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question