Updating InfoPath template after forms exist - InfoPath Dev
in

InfoPath Dev

Updating InfoPath template after forms exist

Last post 09-01-2013 01:37 PM by Patrick Halstead. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 10-21-2009 11:07 AM

    Updating InfoPath template after forms exist

    I have a MOSS forms library. I create an InfoPath form programmatically into the forms library and then when I click on it, it uses the template I've published to this forms library to open up the form.

    So, let's say I have a couple of forms with data in them already in the forms library and I go and change my template, add some fields, remove some fields etc. I change my programmatic code to match, republish the template to the library and all that.

    What will happen when I open one of the older forms? Will it try to use the new template and then not show some of the fields? Will it show new fields?

    Thanks!

  • 10-21-2009 02:48 PM In reply to

    Re: Updating InfoPath template after forms exist

    This all depends on the upgrade settings you have for the form. If you are using automatic upgrade, it will use an auto-generated XSLT to convert your old XML files to the new schema. This generally works well in most cases. However, if you are concerned of data loss, you can always write your own custom upgrade (a lot more complicated) or publish your new template to a new location, or a number of other things.

  • 10-22-2009 05:34 AM In reply to

    Re: Updating InfoPath template after forms exist

    Right now I have things set to automatically upgrade, however what I'm dealing with here are that the people using the forms library still want to be able to go back and see the old forms with it orginal data and fields. In my opinion, I have suggested that we move to a new forms library for the different version.  This same situation exists whether you are using doc libs with Word docs or ASP.Net forms, if you start changing the content types on those, its go to blow away any settings you had in the previous content types.  So this is really nothing new.

     I tried to explain that if we are promoting columns out to the SharePoint forms library, and these columns represents fields that no longer exist in the new form, it's not like they are going to just see an empty column in the forms library for the new form and filled columns for the old form, the column will be gone.

    How would you go about writing your own custom upgrade to handle something like this (if it even can be handled)?

    Thanks!

  • 10-24-2009 02:54 AM In reply to

    Re: Updating InfoPath template after forms exist

    Hi,

    as Greg already posted you can use custom code to handle the version upgrade of your forms. You can find more information regarding this event in the following MSDN article:

    http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.formevents.versionupgrade.aspx

    Below you will find a small code snippet:

    public void FormEvents_VersionUpgrade(object sender, VersionUpgradeEventArgs e)
    {
      string formVersion = e.DocumentVersion;
      string templateVersion = e.FormTemplateVersion;

      //comparison code here
      //if versions are different then do something
    }

    Another option is to ensure that an InfoPath form created from an older version of the form template continue to load from the template version which they were created from, while any new form submitted to the library will always use the latest version of the form template.

    Here you can find an article which demonstrates this in a "step-for-step" description:

    http://blog-sharepoint.blogspot.com/2009/09/infopath-form-content-type-template.html

    Hope that helps...

    Regards,

    Karsten
  • 10-25-2009 10:31 AM In reply to

    Re: Updating InfoPath template after forms exist

    Thanks! This should do what I need.

  • 10-28-2009 08:56 AM In reply to

    Re: Updating InfoPath template after forms exist

    Thanks Karsten for supplying the links.

  • 09-01-2013 09:16 AM In reply to

    • avs270
    • Not Ranked
    • Joined on 09-01-2013
    • Posts 9

    Re: Updating InfoPath template after forms exist

    Hi, What would the code be if I wanted to programmatically update the form? Also do you know how long it takes InfoPath to clear their cache? So for example would it automatically update the version after a certain period of time?
  • 09-01-2013 01:37 PM In reply to

    Re: Updating InfoPath template after forms exist

    There are lots of documents on the Microsoft site that show examples of OnVersionUpgrade event handlers. For example: http://msdn.microsoft.com/en-us/library/office/bb229744(v=office.12).aspx

    The 2003 SDK also has more examples of javascript (2003-2007-2010). JavaScript is not compatible for browser forms, but you can easily convert the code to C# or VB.NET for browser support.

    Keep in mind that your code will depends on your form's source and target versions (data source) and what changes were made. It also depends on which version of InfoPath you are using (since 2003-2007-2010 all have different object models).

    In general, I do not recommend writing code to do OnVersionUpgrade. Why?  Because you have to keep track of all previous versions and the matrix explodes quickly creating a maintenance nightmare.

    What I do recommend is one of the following approaches:

    • Side-by-side
      • old versions open with old templates
    • On demand data migration
      • old version opens with old template, but with link to open in new version
      • link passes input parameter to new template
      • new template uses XSLT transform to map old fields (this is more data-driven and easier to maintain than code)
    • Bulk migration
      • use an XSLT tool (like Qdabra's free DBXL Migration tool or Altova's tools)
      • create an XSLT map for old data
      • run the tool on all old versions 

    During Qdabra's weekly webinar on 2013-08-23, Jennifer Lindsay discussed these techniques.

    Thanks,

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