Populating control value based on drop-down from sharepoint list - InfoPath Dev
in

InfoPath Dev

Populating control value based on drop-down from sharepoint list

Last post 06-30-2011 02:11 PM by Hilary Stoupa. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 06-29-2011 08:47 AM

    Populating control value based on drop-down from sharepoint list

    First off, I'm very new to InfoPath and greatly appreciate any guidance!

     I am working on a form bound to data in two SharePoint lists.  The purpose of the form is to collect deliverables required for a project.  There are two lists involved: Projects and Deliverables.  The Deliverables list is the primary data source, and the Projects list is the secondary data source. The form has a drop-down control which lists all projects from the ProjectName field (which works just fine).  When the user selects a project from the drop-down, I want to prefill another field (ContractID) from the Projects list into a control to store it as a column in the Deliverables list.

    To do this, I'm using a rule attached to the ProjectName drop-down.  It is activated when the value in this control changes.  The action is "set a field's value", and the field I'm setting is the ContractID in the Deliverables list.  When I insert "test" as the value of the field, it works perfectly in preview mode. 

    However, when I change the hard-coded "test" value to a formula, it fails to work.  Based on web research, it looks like I should be applying a filter to the 'insert field or group' option within the formula menu.  But I'm confused - what exactly am I filtering on?  It seems like I should be looking for matching ProjectNames (get the respective ContractID when the ProjectNames match)... I've tried matching the ProjectName in the primary data source to the ProjectName in the secondary data source, but the target field remains empty. 

    Could someone provide some guidance on this?

     thanks so much for your help!

  • 06-29-2011 02:06 PM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    It would probably help if you could attach a copy of your template. Under the Options tab, you can attach a file.

    You are correct that you'll need to use a filter for this, but it will be a lot easier for me to help you when I can see what you are talking about.

    Hilary Stoupa

  • 06-29-2011 02:44 PM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    Hi Hilary:

     Thanks so much for your time!

    I've attached a copy of the template.

    Since I sent the original post, I've managed to get the first item in the secondary table to populate the Project Lead field.  But not the RIGHT item.  I've been researching current() (which makes sense), and trying to figure out where it belongs in the xpath version of the code.  Which is all new stuff to me.

    I so appreciate your help on this!

     

  • 06-29-2011 03:46 PM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    Okay, I added a filter to the rule you have for setting the project lead. I can't preview and test, of course, because I can't access your data sources, but give it a try.

    Save the linked file locally, right click and select design to open in design mode so you can preview.

    Hilary Stoupa

  • 06-30-2011 06:14 AM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    Hi Hilary:

     Ah - so close.  I'm having trouble opening the template - The error says I have to open it from the same location in which it was published.  So I put it in a matching directory structure, but still get the error.  I've attached a pdf which shows both the error and the location of the template (even renamed it to match the filename in the error).  No luck.  Is there a trick to this?

     again, thanks for your time!

    -d

  • 06-30-2011 06:18 AM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    oops - forgot to attach the file (now a jpg) in the previous message.


  • 06-30-2011 07:00 AM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    Hooray, hooray - it works!  It is like magic!  It is like the clouds have parted and the sunshine pours through!  You are my hero!

    (I managed to get the template open from within IP).

    I've also managed to get the filter to prefill other fields by copying the xpath code and modifying the name of the target field.

    For other forms based on different data structures, could you please tell me how you created that magic filter?

     -d

  • 06-30-2011 07:43 AM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    You may not have noticed this in my earlier post - but InfoPath forms aren't crazy about being moved. So after you save a template to a new location, you need to open it in design mode. One way to do that is to right click the file and select Design after you save it locally.

    When you are in the formula editor, and you select a field, you have the option to Filter Data. I could see that your Project Name field in your main data source was using the Project Name from a secondary data source as its drop down values. So, we select the field we want to use the value of, and click Filter Data. Then select the field in the secondary data source that identifies the secondary data source row that will have the correct value - in your case, Project Name. The center drop down in this case is "equals" and the third drop down in the filter is the field in the main data source that identifies which row in the secondary data source we are interested in - in this case, again Project Name.

    The easiest way for me to think of filters (and I understand everyone needs different metaphors, this is just the one that makes sense to me) is as a way to tell InfoPath which row I want. I have a bunch of data in my secondary data source, and I have to define that I want this particular row.

    Hilary Stoupa

  • 06-30-2011 01:42 PM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    Hi again, Hilary:

     It worked, it worked - and I UNDERSTAND why!

    Thank you so much for your time - this is just what I needed to know!

    -d

  • 06-30-2011 02:11 PM In reply to

    Re: Populating control value based on drop-down from sharepoint list

    That is wonderful news, sounds like you've cleared one of the traditional InfoPath hurdles!

    Hilary Stoupa

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