Accessing XSN programmatically - InfoPath Dev
in

InfoPath Dev

Accessing XSN programmatically

Last post 11-25-2008 04:50 PM by Patrick Halstead. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-24-2008 03:50 AM

    Accessing XSN programmatically

     Hello,

    I want to open a form template (.xsn) in infopath in design mode programatically and save it. This is due to the fact that I change the XSD from outside infopath and I have to save/publish the xsn so that the other files in the xsn will be automatically updated (sampledata.xml, template.xml etc.).

    The API toolkit for .NET framework provides a reference to the XDocumentsCollection (the xml form files), but I didn't find a way to retrieve a reference to a template.

    Is there a way to solve my problem?

     

    Thanks.

    Daniel

  • 11-25-2008 05:51 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Accessing XSN programmatically

    Hello Welcome to the Forums, 
    If we want we get any file using programmatically. But we can't change the .xsn file data or any modification will not save in those files. 
    Whatever changes we want to do those should be apply in design mode of the InfoPath. While updating the schema some time it will not reflect in template.xml and sample,xml files. For this we have to add by manually for those new fields in those files.
  • 11-25-2008 03:56 PM In reply to

    Re: Accessing XSN programmatically

     

    Hi Daniel,

    The XSN is just a cab file. You can use the Cab tools to programmatically "package" together an XSN but as Shiva suggests, it's very dangerous. That's because the manifest.xsf should also be updated in the correct way. If it's just an XSD change (an addition of a node), you can do it by saving the files as source (or uncabbing them by renaming the XSN as CAB and double clicking the CAB to get the files out), modifying the XSD and re-cab the form by using MakeCAB or some other utility. But, as you have found out, if you don't modify SampleData and Template.xml it won't necessarily work.

    There is no object model for the InfoPath template. We are looking into creating one, but it's a lot of work, and while we get the request about once every 2-3 months, nobody wants to pay us to do it yet, so we're being lazy. Maybe in 6 months we'll have something for you. On the other hand, if you'd like to see something sooner, and have a checkbook, let me know and we can talk. :)

    Patrick Halstead
    Project Manager at Qdabra
  • 11-25-2008 04:25 PM In reply to

    Re: Accessing XSN programmatically

     Hi Patrick,

    Thank you for answering.

    Actually this matter is quite important, I will forward your suggestion to my managers.

    Any way, the best way to do it would probably be to deal with the xml changes ourselves...

  • 11-25-2008 04:50 PM In reply to

    Re: Accessing XSN programmatically

    Hi again,

    What exactly do you want to do? Is it just updating the schema (XSD) and sampledata/template.xml? What about the view? Usually, for these "data driven" forms, we find that a very generic view is required with a lot of hide/show. We have done data driven XSNs before where the schema is normalized and the XSN is designed to allow any kind of node. The resulting XML data gets created on submit. In this way, one XSN can handle any number of schemas, but the view must be designed in a way to allow variable length sections and that means making it lay out vertically which presents some look-and-feel limitations. It's fine for online surveys and things like that, but not for *typical* paper forms. For example, try doing the IRS 1040 ES in a vertical layout and most of your users won't know what the form is because it stopped looking like the form they were used to seeing.

    If it's a limited application, we'd be happy to look into it for you. Best of luck!

     

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.