InfoPath 2007 - Manually adding records to Repeating Table - InfoPath Dev
in

InfoPath Dev

InfoPath 2007 - Manually adding records to Repeating Table

Last post 07-26-2010 04:43 PM by Hilary Stoupa. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-26-2010 03:53 PM

    InfoPath 2007 - Manually adding records to Repeating Table

     I am trying to pull data from a sharepoint list, and then manually add the data to a form. This will allow for me to do some customization on the data but for right now I just want to display everything. When I use the below code it throws an error

     

                XPathNavigator domNavAgent = MainDataSource.CreateNavigator();
    string value = domNavAgent.SelectSingleNode("/my:myFields/my:Agent", NamespaceManager).Value;

    if (value.Equals(""))
    return;

    XPathNavigator domNav = this.DataSources["AuditLog"].CreateNavigator();

    XPathNodeIterator rows = domNav.Select("/dfs:myFields/dfs:dataFields/dfs:AuditLog", NamespaceManager);

    while (rows.MoveNext())
    {
    string IncidentNumber = rows.Current.SelectSingleNode("@Incident_Number").ToString();
    string Score = rows.Current.SelectSingleNode("@Score").ToString();
    string Notes = "Unknown";
    string Created = rows.Current.SelectSingleNode("@Created").ToString();
    string CreatedBy = rows.Current.SelectSingleNode("@Created_By").ToString();

    string my = NamespaceManager.LookupNamespace("my");
    StringBuilder sb = new StringBuilder();
    sb.Append("<my:PreviousAudit xmlns:my=\"");
    sb.Append(my);
    sb.Append("\">");
    sb.Append("<my:IncidentNumber xmlns:my=\"");
    sb.Append(my);
    sb.Append("\">");
    sb.Append(IncidentNumber);
    sb.Append("</my:IncidentNumber>");
    sb.Append("<my:Score xmlns:my=\"");
    sb.Append(my);
    sb.Append("\">");
    sb.Append(Score);
    sb.Append("</my:Score>");
    sb.Append("<my:Notes xmlns:my=\"");
    sb.Append(my);
    sb.Append("\">");
    sb.Append(Notes);
    sb.Append("</my:Notes>");
    sb.Append("<my:Created xmlns:my=\"");
    sb.Append(my);
    sb.Append("\">");
    sb.Append(Created);
    sb.Append("</my:Created>");
    sb.Append("<my:CreatedBy xmlns:my=\"");
    sb.Append(my);
    sb.Append("\">");
    sb.Append(CreatedBy);
    sb.Append("</my:CreatedBy>");
    sb.Append("</my:PreviousAudit>");
    MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:PreviousAudits", NamespaceManager).AppendChild(sb.ToString());
    }

     Error on bold line: Operation is not valid, because of the current state of the object.

    Does anyone see what is wrong with this? Maybe there is a easier way to manually add each row?

  • 07-26-2010 03:54 PM In reply to

    Re: InfoPath 2007 - Manually adding records to Repeating Table

     Sorry the bold line didnt actually become bold. Here is the line that throws the error

     

    MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:PreviousAudits", NamespaceManager).AppendChild(sb.ToString());

     

  • 07-26-2010 04:43 PM In reply to

    Re: InfoPath 2007 - Manually adding records to Repeating Table

    What event is this code running in? Data is read only in Changing and Validating events....

    Hilary Stoupa

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