Load xml from db on form load - InfoPath Dev
in

InfoPath Dev

Load xml from db on form load

Last post 10-16-2014 07:10 AM by SteveJones. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 01-24-2013 11:32 AM

    Load xml from db on form load

    I have a large infopath form that is filled out and submitted. Upon submission the xml is saved into a database ntext field.

     Later when the form is opened I want to load the xml from the db (it could have been modified by an external process). Any clues on how to do this?

    Steve
  • 01-26-2013 02:57 PM In reply to

    Re: Load xml from db on form load

    Hi Steve,

    What are you drinking in your avatar picture?

    To answer your question, you would ideally create a Web service that could run a query to get the XML from SQL. There are a lot of tricks to do this corectly, for example you need to make sure that you don't strip out the processing-instructions at the top of the XML that tell Windows or the browser that it's an InfoPath. Otherwise, it just opens plain XML.

    Fortunately, we've done all the work to make this easy and we have an inexpensive Web service called  DBXL that has a Web method called GetDocument which supports this. It also supports submitting the forms and a boatload of other features.

    Also, keep in mind that just getting the XML may not be all you have to do. You may have to swap the XML out from the newly opened form and replace it with this XML. The qRules plugin for InfoPath has a SwapDom command that was especially created for this task. There's a free trial for both and the products are inexpensive and easy to setup, plus Qdabra provides incredible support.

    On the other hand, you could write code to do it yourself, but you'd have to figure that out and do it and it would take oodles of time and you may get stuck. We've done all of the work for this scenario and are here to help. The InfoPathDev forum is free. We pay our employees to respond to posts in the forum and we watch the metrics weekly to make sure we are above 90%. In order to support that effort, we sell these essential tools. They save you time and money and help us keep the forum going. 

    Thanks for your support,

    Patrick Halstead
    Project Manager at Qdabra
  • 01-28-2013 05:51 AM In reply to

    Re: Load xml from db on form load

    Hi Patrick,

    That is a 6 oz bottle of a homebrewed Barleywine (a very strong pale ale) that I made in 1999. It won Best of Show at the national homebrew competition in 2001.

    I am really close to getting this to work. My web service method does return the xml with the processing instructions, and I'm thinking that I need to use xpath replaceself on the root node, but that is a bit tricky to get working. I do have an instance of this process that is working with an Infopath 2003 form with VB Script (I did not write that one). I'm trying to convert that process to Infopath 2010 using C# ... figuring out the equivalent objects and syntax is my real challenge.

    Steve
  • 10-14-2014 07:56 PM In reply to

    Re: Load xml from db on form load

     Hi Steve,

    Sorry I never responded. Congrats on the best of show beer. How was it after 10+ years?

    Did you ever get it to work?

    We had another customer ask us the same question today.  SwapDom is an easy and codeless way to do it.

    Cheers, 

    Patrick Halstead
    Project Manager at Qdabra
  • 10-16-2014 07:10 AM In reply to

    Re: Load xml from db on form load

    Alas ... that picture was taken around 2006 or so. it was my last bottle, and it was even better than in 2001.

    Yes, I got it working. I created a web service method to retrieve the xml from the database, added a data connection in Infopath. 

    In FormEvents_Loading I do the following:

    1. Create an xpath navigator on main datasource
    2. query the connection
    3. load the xml into an xmldoc
    4. then using xpathnav.replaceself I selectively replace specific nodes in xnav with the same nodes in xdoc
    Steve
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.