3

I am creating an InfoPath form and want to retrieve the data from the SQL database. I'm not looking for end users to fill in blank text fields, but rather am just wanting to populate the fields with the data from the SQL Database.

I have searched on some blogs and InfoPath/Microsoft sites to see how this can be accomplished, but many of the things I keep bumping into show how to create fields that the end user can populate instead of fields that are pre-populated.

I have already connected the database that I want to use to InfoPath and 'myfields' are already populated with the table that I am using, so half the battle has been won! :)

How can I accomplish this?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Richell
  • 315
  • 2
  • 10
  • 22

1 Answers1

1

There are a few options available to you...

Firstly, you can look at using rules on the form load or default vlues in your InfoPath forms' fields to populate the fields with data from your SQL (secondary) data source... Take a look at this link here: http://social.technet.microsoft.com/Forums/en/sharepoint2010customization/thread/cb15a237-28cc-4d6b-8225-83181a7497ff

Secondly, you could use managed code on the form load to query the SQL database and then set your returned values to the values held in your fields in your InfoPath form. Take a look here for using managed code to do this: http://vspug.com/ssa/2006/01/03/populating-infopath-fields-with-sql-data-using-managed-code/

I hope this helps...

Luke
  • 422
  • 5
  • 15
  • @Luke- Ok I had checked out the first link and followed the instructions. However, after I save my work and preview it, I have a drop down with employee names, but the data that is associated with the employee name isn't populating the field. *scratches head* I am going to keep plugging away at this, but if you have any other ideas or thoughts, I'd greatly appreciate it. :) thank you. – Richell Feb 15 '11 at 19:43
  • @Luke- Oh, and I had checked out the second link earlier before I asked my question on here...eh...I guess I can look at it again. – Richell Feb 15 '11 at 19:44
  • @CompGeekess - ahh that makes it a little easier, if the user selects themselves from a drop down box then you can use rules (or managed code) on the field that the drop down box is connected to... I hope this helps... – Luke Feb 15 '11 at 22:09
  • @Luke- what I have noticed with the rules (managed code) is this. When I want FullName (this dropdown works), the rule I am using is: @Telephone[@FullName = @FullName] and this seems to be working for the dropdown. However, for example let's use the Telephone field: when I use @FullName[@Telephone = @Telephone] under value, save and preview the page, select a name from the drop down, nothing is populated in the Telephone field, unless it's a default number, so if I use @Telephone, a default number is displayed and when I change the name from the dropdown, Telephone doesn’t change. – Richell Feb 16 '11 at 13:00
  • 2
    @CompGeekess - That is what i would expect as the rule is setting the value based on the full name that is selected being the full name of the person in the SQL datasource. If you want to set the value as a (calculated) default value on the telephone field instead of rules on the drop down field you do it in the same way so the default value would be still @Telephone[@FullName = @FullName]. I hope that makes sense and helps you out.. – Luke Feb 18 '11 at 00:40
  • @Luke- Thank you, to be honest I'm still a bit confused. I have been playing around with the rules to see how to get this to work, but the only thing that has been working thus far is the drop-down. When I select a name, I am requested to enter my SQL password (something I dont want the end user to do- take care of this later), but nothing populates in the text fields, so I am thinking I may want to add a 'button' not so sure though. If I don't need a button, I'd rather not have one. Thank you for your helping me Luke. I've been looking all over for a solution, not much luck. – Richell Feb 21 '11 at 19:52
  • @CompGeekess - I hope I have helped out a little at least and it seems you are on the right track... The password can be solved when making the data connection, you have the ability to tell the connection to save the credentials which should clear that issue up... If you think this is the answer please mark as answered. If there is anything else I can help with on this, please let me know. Cheers – Luke Feb 21 '11 at 22:18
  • @Luke- to be honest I became frustrated and removed ALL of the rules and decided that I will re-establish the rules tomorrow. As far as the password, I'm not so sure, but will let you know tomorrow if it works out. – Richell Feb 22 '11 at 19:06
  • @ Luke, I am going to go ahead and close this out...I still havent found a resolution to this question, but will continue to work on it. thank you for all of your help. – Richell Mar 03 '11 at 16:54