Filter received Data Connection - InfoPath Dev
in

InfoPath Dev

Filter received Data Connection

Last post 12-17-2012 11:37 AM by kalehm. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-14-2012 07:29 AM

    • kalehm
    • Not Ranked
    • Joined on 12-13-2012
    • Posts 2

    Filter received Data Connection

    Hi to all!! First of all, I'm newbie on InfoPath.  I start like 5 days ago but I manage to do some crazy stuff and a lot of programming using a lot of codes from here and some other pages. But like any programmer, I don't know everything... :( Let me put my scenario and see if someone has the codes that I need. 
    • I have in SharePoint 2007 a Form Library and a List.
    • In my SharePoint Library and in the List there is a field call Training.
    • I have an InfoPath 2007 Form that use the codes from http://msdn.microsoft.com/en-us/library/cc162745(office.12).aspx to connect to the List and fill it, and some fields that fill the data to the Library.
    • I manage to create a single button to submit both data.
    • Even I learn how to create a Web Part in SharePoint to show both data and filter the list base on what you select in the library.
    I learn all this in just 5 days.  So far, so good. So, my problem is that I need to filter the List in the InfoPath Form so if you open a new Form the list in the Form appear empty and if you open a Form from the list that already you enter the items in the list appear in the Form.  Sorry for my English... My nature language is Spanish.
  • 12-17-2012 11:37 AM In reply to

    • kalehm
    • Not Ranked
    • Joined on 12-13-2012
    • Posts 2

    Re: Filter received Data Connection

    I found it... Part of the codes come from this site http://social.msdn.microsoft.com/forums/en-US/sharepointcustomizationlegacy/thread/403e6f25-ff23-472c-b414-c17866607181

    Just if someone is looking for this my codes look like this:

     

    // Get the name for the InfoPath title

    string selectedXMLFile = MainDataSource.CreateNavigator().SelectSingleNode(

    "/my:myFields/my:Title1", NamespaceManager).Value;

    // Get the date

    string selectedDate = MainDataSource.CreateNavigator().SelectSingleNode(

    "/my:myFields/my:Date", NamespaceManager).Value;

    // Retrieve the data connection

    FileQueryConnection con = (FileQueryConnection)DataConnections["items"];

     

    // Change the location of the data connection to point to the XML file created

    con.FileLocation = @"Server/_vti_bin/owssvr.dll"

    + "?Cmd=Display&List={GUID}"

    + "&XMLDATA=TRUE&noredirect=true&FilterField1=Training&FilterValue1="

    + selectedXMLFile + " - " + selectedDate + ".xml";

    // Query the data connection to populate the InfoPath drop-down list box with items

    con.Execute();

     

     

    // Retrieve a reference to the Main DOM

    XPathNavigator root = MainDataSource.CreateNavigator();

    // Count the amount of group2 nodes

    XPathNodeIterator iter = root.Select("/my:myFields/my:gpContacts/my:gpContact",

    NamespaceManager);

    int group2NodesCount = iter.Count;

    // Retrieve the first group2 node

    XPathNavigator firstGroup2NodeNav =root.SelectSingleNode("/my:myFields/my:gpContacts/my:gpContact[1]",

    NamespaceManager);

    // Retrieve the last group2 node

    XPathNavigator lastGroup2NodeNav =

    root.SelectSingleNode("/my:myFields/my:gpContacts/my:gpContact[" +

    group2NodesCount.ToString() + "]",

    NamespaceManager);

    // Delete the range of nodes from the first to the last group2 nodes

    firstGroup2NodeNav.DeleteRange(lastGroup2NodeNav);

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