Programmatically populating repeating tables with blank dates - InfoPath Dev
in

InfoPath Dev

Programmatically populating repeating tables with blank dates

Last post 07-20-2011 11:16 AM by Patrick Finnicum. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-20-2011 08:16 AM

    Programmatically populating repeating tables with blank dates

    TIA for any and all consideration and positive comments.

    I'm trying to copy elements from a datasource into a repeating table.  I've found success all except for populating blank dates.  I've scoured the forum and found a few comments about the xsi:nil tag, but (from what I could decipher) those were geared towards javascript and creating tables on the fly.

    Here's my code thus far:

    [snip]


                XPathNavigator referencedNav = this.DataSources["referenceDS"].CreateNavigator();
                XPathNavigator rootNav = this.MainDataSource.CreateNavigator();
               
                string selectedItemsXPath = "/my:myFields/my:grpItemsSelected";

                foreach (XPathNavigator people in referencedNav.Select(otherSelectedItemsXpath, NamespaceManager))
                {
                    if (people.SelectSingleNode("Selected", NamespaceManager).Value.ToLower() == "yes")
                    {
                        string myNamespace = NamespaceManager.LookupNamespace("my");
                        using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode(selectedItemsXPath, NamespaceManager).AppendChild())
                        {
                            writer.WriteStartElement("selectedItems", myNamespace);
                            writer.WriteElementString("Selected", myNamespace, "no");
                            writer.WriteElementString("priKey", myNamespace, people.SelectSingleNode("priKey", NamespaceManager).Value.ToLower());
                            writer.WriteElementString("FirstName", myNamespace, people.SelectSingleNode("FirstName", NamespaceManager).Value.ToLower());
                            writer.WriteElementString("LastName", myNamespace, people.SelectSingleNode("LastName", NamespaceManager).Value.ToLower());
                            writer.WriteElementString("startdate", myNamespace, "");
                            writer.WriteElementString("enddate", myNamespace, "");
                            writer.WriteEndElement();
                            writer.Close();
                        }
                    }
                }

    [/snip]

    My problem then becomes that IP doesn't accept blank dates and gives the dreaded "some rules were not applied" error upon submit.  Has anyone tackled this problem using C# and the writeelementstring approach I've outlined above?

    Thanks again.

  • 07-20-2011 11:16 AM In reply to

    Re: Programmatically populating repeating tables with blank dates

    just as a followup...  i've tried the deletenil approach to no avail.

    found this approach:  http://social.msdn.microsoft.com/Forums/eu/sharepointinfopath/thread/53803456-c1f0-4a7e-91d0-c44df2965877 which suggests to change the base data type to a string.  seems to work for what i'm trying to accomplish.

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