Populating a repeating table from a Sharepoint List - InfoPath Dev
in

InfoPath Dev

Populating a repeating table from a Sharepoint List

Last post 10-14-2010 11:16 AM by Potemkine. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-13-2010 06:09 AM

    • jkuni
    • Not Ranked
    • Joined on 10-12-2010
    • Posts 3

    Populating a repeating table from a Sharepoint List

    I found a few tutorials online regarding this and am having trouble getting it working 100%.

    I have 7 rows in a list of emails, MyContacts.  The repeating table will fill 7 rows, but each row is filled with the information from the first row, say  first name - John  last name- Doe email- [email protected].

    I know that row is actually progressing and holding the values of the next row in the list, and when i do row.Current.Value it actually spits out the entire next row correctly.

    code :

     DataSource ds = DataSources["MyContacts"];

    XPathNavigator domNav = ds.CreateNavigator();

    XPathNavigator listNav = ds.CreateNavigator();XPathNodeIterator rows = listNav.Select("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW", NamespaceManager);

     

     

    while (rows.MoveNext())

    {

    string lastName = rows.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:LastName", NamespaceManager).Value.ToString();

     

    string firstName = rows.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:FirstName", NamespaceManager).Value.ToString();string email = rows.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Email", NamespaceManager).Value.ToString();

     

    AddItem(lastName, firstName, email);

     

    I assume something is going wrong with the SelectSingleNode, and the xpath attribute to pull from.  Any help would be much appreciated. 

  • 10-13-2010 06:24 AM In reply to

    Re: Populating a repeating table from a Sharepoint List

    Hi, I think you have a problem with your Xpath. You don't paste you "rows" line so I can be sure but I suppose you have to change all your "/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:FirstName" by just "d:FirstName", "d:Email","d:LastName"

  • 10-13-2010 06:38 AM In reply to

    • jkuni
    • Not Ranked
    • Joined on 10-12-2010
    • Posts 3

    Re: Populating a repeating table from a Sharepoint List

    Yeah that worked.  I figured it would be something very small.  Thank you. 

  • 10-13-2010 06:45 AM In reply to

    Re: Populating a repeating table from a Sharepoint List

    Your welcome !

  • 10-14-2010 06:07 AM In reply to

    • jkuni
    • Not Ranked
    • Joined on 10-12-2010
    • Posts 3

    Re: Populating a repeating table from a Sharepoint List

    Since I got that working, I am trying to do the same process for an entire form. The overall goal is to have users create a new form, have everything autopopulate, then have the user able to check the rows that are needed, so that we can then use the xml to pull out only those rows to make a presentation view. I've got a basic structure as follows Selected, Category Type Requirement Requestor Value Date being the columns, and category, type, requirement being strings, value a drop down between H,M,L, requester a person and date date. Selected is the actual boolean check list. Now my problem is I get a null error when I use, even though selected shows the value of false. string selected = rows.Current.SelectSingleNode("xSelected", NamespaceManager).ValueAsBoolean.ToString(); So my first question would be how to solve this, and secondly is what I am trying to do even possible? I don't want the data to be uplaoded to a sharepoint list, rather be able to create a view in sharepoint to pull out only the selected fields from the xml. Sorry, basically new to Infopath and Sharepoint. Thanks for any help.
  • 10-14-2010 11:16 AM In reply to

    Re: Populating a repeating table from a Sharepoint List

    Hi, just a comment on that:

    string selected = rows.Current.SelectSingleNode("xSelected", NamespaceManager).ValueAsBoolean.ToString();

    you can just do :

    string selected = rows.Current.SelectSingleNode("xSelected", NamespaceManager).Value;

    it's the same and simpler.

    For your current problem, You probably need to remove the xsi:nil attribute. Here a sample of code to remove it:

    IXMLDOMNode FullBooleanNode = thisXDocument.DOM.selectSingleNode("//my:Node");
    removeNil(FullBooleanNode ).text = "true";

    public IXMLDOMNode removeNil(IXMLDOMNode node)
    {
    if (node.selectSingleNode( "@xsi:nil" ) != null)
    node.selectSingleNode( "@xsi:nil" ).text = "false";

    return node;
    }

    you can make a  search on google for more detail.

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