locked
How can a form be configured so that on selection of a value in a drop down (Project name) other fields are populated? RRS feed

  • Question

  • Hi,

     

    I have  a form with these fields on:

    1. Project Name
    2. Project Code
    3. Business Area

    The information for the above is in a sharepoint list. I have a datasource that shows Project Names in a drop down on my Forms Services enabled form.

    I want the other 2 fields to show values from the datasource (my sharepoint list) when i select the Project name.

    Can this be done without code?

    If you need code, what is it or where can I look to understand this better?

    Thanks!

     

     

     

     

    Friday, February 11, 2011 7:00 PM

Answers

  • Hi, this can be done without code :).

    What you do is set the default value of Project code & Business Area. 

    Project code:

    • Right click Project Code
    • Properties
    • Click the "fx" button next to the default value
    • Click "Insert a field"
    • Change the datasource to your secondary data connection that connects to the SharePoint library
    • Select the Project Code filed
    • Click filter
    • First dropdown box select a field or group:  Project Name (the field from your main datasource that the user selects in the form)
    • Middle dropdown:  Equals
    • Third dropdown:  Select a field or group:  Project Name (the field from your secondary datasource that is the sharepoint connection)
    • Click Ok a bunch of times
    • Test it
    • Follow the same steps for Business Area, of course replacin ghte Project Code fields with the appropriate Business Area fields
    Friday, February 11, 2011 7:08 PM
  • The other option, which I typically use, is to add a rule to the Project Names field with two "set a field's value" actions that set the other field values to the relevant fields of the specified row of data.  You specify the row of data by matching the Project Name in InfoPath to the Project Name field in the secondary data source just like Melli explained.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Saturday, February 12, 2011 1:58 AM

All replies

  • Hi, this can be done without code :).

    What you do is set the default value of Project code & Business Area. 

    Project code:

    • Right click Project Code
    • Properties
    • Click the "fx" button next to the default value
    • Click "Insert a field"
    • Change the datasource to your secondary data connection that connects to the SharePoint library
    • Select the Project Code filed
    • Click filter
    • First dropdown box select a field or group:  Project Name (the field from your main datasource that the user selects in the form)
    • Middle dropdown:  Equals
    • Third dropdown:  Select a field or group:  Project Name (the field from your secondary datasource that is the sharepoint connection)
    • Click Ok a bunch of times
    • Test it
    • Follow the same steps for Business Area, of course replacin ghte Project Code fields with the appropriate Business Area fields
    Friday, February 11, 2011 7:08 PM
  • The other option, which I typically use, is to add a rule to the Project Names field with two "set a field's value" actions that set the other field values to the relevant fields of the specified row of data.  You specify the row of data by matching the Project Name in InfoPath to the Project Name field in the secondary data source just like Melli explained.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Saturday, February 12, 2011 1:58 AM
  • I have used Clayton's method as well and it works well.  Sometimes it seems to update more reliably than the default value for some reason.  However, rules take more time to run than default values so if you have a lot of rules set in your form users will notice "slowness".  Therefore, I usually try to go with the default value first, then if I do not get the result I desire, I change it to a rule (of course you have to completely remove the default value formula otherwise the two will "fight"). 
    Saturday, February 12, 2011 2:27 AM
  • I haven't had the same experience, and I use rules and default values like they're going out of style.  All of my forms are browser forms, so I have to worry about performance quite a bit.  One of the most important things is the # of postbacks, and if you use defult values that are set to run on updates, then it causes more postbacks than a rule, which only runs when the associated field changes.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Saturday, February 12, 2011 4:08 AM
  • I use rules and default values like they're going out of style as well - they are extremely useful.  I think that's our difference - the form that is used most often in our company is too complex (it uses master/detail relationships, combo boxes, etc.) to be a browser-enabled form, so my users are filling it out in the client application.  They notice when some rules run; such as when they make a selection from a dropdown which sets filtered values based off their selection, the form shows the spinning circle for a couple of seconds.  When I use default values instead they don't get the "spinning circle" so they don't notice a slowdown.  The different experiences are definitely interesting and something to keep in mind when planning the design of a form - whether it will be browser-enabled or not. 
    Saturday, February 12, 2011 3:31 PM
  • Yeah, I haven't had the luxury of creating a Filler form in over 3 years, because I can never be guaranteed that the user will be on a Windows machine with the proper version of InfoPath installed.  All it takes is one Mac, and if there is any chance of anyone in the future not having  Windows+InfoPath, then the solution has to be built in the browser, which makes it tough.  I just got done converting someone else's Filler form to a browser form, and it was a nightmare due to it being 2007.  If it was a 2010 browser form, then it wouldn't have been so bad.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Saturday, February 12, 2011 4:19 PM
  • Thanks for the info.

    Both your suggestions sound good - I actually used the rules option which i found on infopathdev.com - nice site that one.

    Monday, February 21, 2011 5:23 PM