Autopopulate Static Fields after a Drop Down Selection - InfoPath Dev
in

InfoPath Dev

Autopopulate Static Fields after a Drop Down Selection

Last post 04-08-2009 07:40 PM by PAWInfo. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 04-07-2009 07:19 PM

    • PAWInfo
    • Top 200 Contributor
    • Joined on 09-14-2008
    • Melbourne, Australia
    • Posts 52

    Autopopulate Static Fields after a Drop Down Selection

    Hello,

     I have a data connection that goes to a Code Table which allows the user to select the code they want to change.

    This part I have working fine.  They select the code in the drop down no problem, from a list of valid codes from our database.

     What I want to happen, is the 6 fields below get populated based on the selection of the code so the user can see the

    fields below.

     Code      Short Name    Long Name    Description    Start Date   End Date

    So, my question is, if the user selects a code from the drop down box, how can I populate these 6 fields above based on the code they select.

     PAW

  • 04-07-2009 07:43 PM In reply to

    Re: Autopopulate Static Fields after a Drop Down Selection

    Are the other five fields coming from the same data source as the codes?  If so, could you make a simple diagram of how the source is structured?

    Will this be in a repeating table/section, or will there just be one section like this in your form?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-07-2009 08:09 PM In reply to

    • PAWInfo
    • Top 200 Contributor
    • Joined on 09-14-2008
    • Melbourne, Australia
    • Posts 52

    Re: Autopopulate Static Fields after a Drop Down Selection

    Yes, exact same source.

    SQL in Data Connection:

    SELECT Code, CodeShortName, CodeLongName, CodeDescription, CodeStartDate, CodeEndDate,

    Code + ' - ' + CodeDescription as ResponseEntity

    FROM dbo.tmpPW_RPS_CodeTables

    WHERE CodeTableClassName = 'Response Entity'

    AND (CodeEndDate is null OR CodeEndDate > getdate())

    ORDER BY Code

     Dropdown uses ResponseEntity.

    So Something like this below:

    (No luck on getting my picture into this Forum.)

    As you can see, I have the drop down working.

    PAW

  • 04-07-2009 08:20 PM In reply to

    • PAWInfo
    • Top 200 Contributor
    • Joined on 09-14-2008
    • Melbourne, Australia
    • Posts 52

    Re: Autopopulate Static Fields after a Drop Down Selection

    Okay, how can I show you the Form easily?  <ALT> Print Screen into a .bmp file, but how does one get that into a post?

    Or is there an easier way?

    PAW

  • 04-07-2009 09:06 PM In reply to

    Re: Autopopulate Static Fields after a Drop Down Selection

    If you click the Options tab when entering a post on this forum, you can attach files to your post.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-07-2009 09:57 PM In reply to

    • PAWInfo
    • Top 200 Contributor
    • Joined on 09-14-2008
    • Melbourne, Australia
    • Posts 52

    Re: Autopopulate Static Fields after a Drop Down Selection

    Duh! 

    Thx Jimmy.

  • 04-07-2009 10:18 PM In reply to

    Re: Autopopulate Static Fields after a Drop Down Selection

    Ok, thank you.  Please try these steps:

    • Right-click a field whose value you want to auto-populate (e.g., the textbox to the bottom left of "Response entity") and choose Properties
    • Click the fx icon in the Default Value section
    • Click Insert Field or Group...  and select the corresponding field in your secondary data source.
    • Check Edit XPath.  The contents of the formula box should look something like this, though the underlined parts will differ:
      xdXDocument:GetDOM("TestTable1")/dfs:myFields/dfs:dataFields/d:TestTable1/@Column1
    • Append the following to the end of that formula, replacing the underlined part with the appropriate value:
      [../@Code = current()/../my:code]
    • The whole thing should look something like this:
      xdXDocument:GetDOM("TestTable1")/dfs:myFields/dfs:dataFields/d:TestTable1/@Column1[../@Code = current()/../my:code]
    • Click OK several times and preview the form

    That's the general idea.  Please give that a try and let me know if you get stuck.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-08-2009 04:19 PM In reply to

    • PAWInfo
    • Top 200 Contributor
    • Joined on 09-14-2008
    • Melbourne, Australia
    • Posts 52

    Re: Autopopulate Static Fields after a Drop Down Selection

    Jimmy,

    Got it!  Thanks! Perfecto!

    Now, what I was trying to do is a little more complicated than I thought.

    So, 1st field works.

    xdXDocument:GetDOM("RPS - Response Entity")/dfs:myFields/dfs:dataFields/d:tmpPW_RPS_CodeTables/@Code[../@Code = current()/../my:TerminationRespEnt]

    2nd Field:

    xdXDocument:GetDOM("RPS - Response Entity")/dfs:myFields/dfs:dataFields/d:tmpPW_RPS_CodeTables/@CodeShortName[../@Code = current()/../my:TerminationRespEnt]

    3rd and so on would be just replacing the underlined info.

    Again, thanks!

    Is this possible:

    If I make the drop down [my:TerminationRespEnt] actually --> Code + ' - ' + CodeDescription as ResponseEntity

    Code is the key, but by using a concatenated column (ResponseEntity), can I still do it?

    PAW

  • 04-08-2009 06:20 PM In reply to

    Re: Autopopulate Static Fields after a Drop Down Selection

    Hello again,

     Glad everything went off without a hitch.  Using ResponseEntity in the dropdown box should be fine as long as the values are unique (and it appears they are).  You could also choose to use ResponseEntity as the Display field for the dropdown box, and Code as the Value field, which would allow you to keep the rest of your setup the way it is.

     InfoPath controls are merely a visual representation of the data, while the data itself exists behind the scenes.  So you could for example, have the dropdown box bound to the my:Code field while displaying the ResponseEntity value, have a text box/expression box bound to the same my:Code field and actually displaying its value, and have the my:TerminationResponseEnt field populated behind the scenes the same way as you're doing now, without actually binding it to a control.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-08-2009 07:40 PM In reply to

    • PAWInfo
    • Top 200 Contributor
    • Joined on 09-14-2008
    • Melbourne, Australia
    • Posts 52

    Re: Autopopulate Static Fields after a Drop Down Selection

    Thx mate!

    The users love it.  I appreciate the help!

    PAW

Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.