Update secondary data connection in code - owssvr.dll - InfoPath Dev
in

InfoPath Dev

Update secondary data connection in code - owssvr.dll

Last post 04-16-2012 02:36 PM by Hilary Stoupa. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-16-2012 10:53 AM

    Update secondary data connection in code - owssvr.dll

    I have a secondary data connection to a custom SP 2010 list using IP 2007 called "FilterOwssrv".

    FilterOwssrv url is: https:///_vti_bin/owssvr.dll?XMLDATA=1&List={list guid} I know that it will retrieve my data as if I hardcode the filters to the end of my url it will return the XML doc with the single record I am looking for from my list. Here is my routine for rebuilding Secondary Data Connection but I keep getting error messages about "Invalid Token"

    private void SetFPDSOptions()
            {
                MessageBox.Show(GetJoinValue());
                XPathNavigator nav = this.CreateNavigator();
                string spListJoin = (string)nav.SelectSingleNode("XPathNavigator nav = this.CreateNavigator();", this.NamespaceManager).ValueAs(typeof(string));
                FileQueryConnection q = (FileQueryConnection)this.DataConnections["FilterOwssvr"];
                q.FileLocation = q.FileLocation + "&FilterField1=Join&FilterValue1=" + GetJoinValue();
                try
                {
                    q.Execute();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to query." + System.Environment.NewLine + ex.Message);
                }
            } 

    So I have my existing secondary data connection fields on my form so that when I change the connection by adding the filter it will auto populate my form Please help!!!! Thanks, Bragaidan

  • 04-16-2012 11:21 AM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    Hi - among other things, what is this:

    string spListJoin = (string)nav.SelectSingleNode("XPathNavigator nav = this.CreateNavigator();", this.NamespaceManager).ValueAs(typeof(string));

    SelectSingleNode takes an XPath to the node you wish to select...Here's a link to the MSDN docs.

    (qRules has a command for this - much easier than writing your own code if you aren't a programmer - free trial here.)

    Hilary Stoupa

  • 04-16-2012 11:31 AM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    In fact, you don't seem to be using spListJoin at all - so perhaps just do away with that line? What does your GetJoinValue() method do?

    Hilary Stoupa

  • 04-16-2012 11:43 AM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    GetJoinValue just retrieves the value of a text field that is what I am filtering the list for, basically it is 3 fields concatenated to make the record I am looking for unique. I could do it in the same routine but I was trying separate it out for troubleshooting purposes. I would love to use qRules, but its a highly controlled environment and I cannot inject anything that isn't native to SharePoint and MS Office without significant impact to project. I have never worked with XML and just saw this as an easy way to do some data integration. Basically I am using this secondary data connection to search for the existence of contract data and if it finds it, based on my join field, then I can review it and I have another command button that copies it to the Main Data Source for submittal if the use chooses to do so. Challenge is that the secondary list is over 50,000 records and growing. I have repeating section on the "Search View" of my form that is the data fields from the secondary connection (FilterOwssvr) so that when I perform my search and it returns something, it will automatically populate that table with the single record it finds. I am just not sure how to go about it. I REALLY APPRECIATE YOUR HELP.
  • 04-16-2012 11:51 AM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    So, if you remove these lines:

     XPathNavigator nav = this.CreateNavigator();
    string spListJoin = (string)nav.SelectSingleNode("XPathNavigator nav = this.CreateNavigator();", this.NamespaceManager).ValueAs(typeof(string));

    What happens?

    Hilary Stoupa

  • 04-16-2012 12:14 PM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    Dope, I had conditional formatting that hid the repeating section if it was null and when I removed the formatting, voila.

     THanks a heap.  Been looking at it for tooooo long.

    Last issue is that I am returning dates from my secondary data source and when I copy those fields to date fields in main data source I have validation problems as I the secondary data source dates come in as "yyyy-mm-dd hh:mm:ss instead of m/d/yyyy

    Any thoughts?

  • 04-16-2012 12:23 PM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    Is your main data source a date data type? Or date time?

    If date, use the substring-before function to get the data bafore the space. If datetime, use translate to replace the space with an uppercase T. Look at an XML file in a text editor to see how InfoPath is storing the date values - select a date using a date picker and then save the XML and take a look.

    Hilary Stoupa

  • 04-16-2012 02:31 PM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    I was able to grab the date using substring-before function.  Thanks for all of your assistance.  I am now able to filter my 50,000+ record SP list on the server side and bring a record back in just a few seconds.

    Thanks,
    Bragaidan

  • 04-16-2012 02:36 PM In reply to

    Re: Update secondary data connection in code - owssvr.dll

    You bet - glad you got it working!

    Hilary Stoupa

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