Wednesday, November 16, 2016

Recipe to duplicate InfoPath ListForm template for another content type

Context:
  • Crafted a rather rich and extensive InfoPath ListForm for content type <X>
  • Business requests similar but slightly different form for content type <Y>
Difficulties
  • InfoPath Designer does not provide a native capability to duplicate an InfoPath form to another content type
  • Drag-and-Drop from source InfoPath form template opened in InfoPath Designer to destination form template is limited, incomplete layout, no controls binding, ...
Pragmatic recipe for InfoPath Form copy
  1. Navigate to SharePoint List in a browser
  2. Go to 'List settings' \ 'Form Settings'
  3. Select content type <X>, the associated form opens in InfoPath Designer
  4. Save the template.xsn on a local location (or 'Save as' of the "source files")
  5. Return to 'List settings' \ 'Form Settings'
  6. Select content type <Y>, and select to create new form in InfoPath
  7. Immediate save as template.xsn on a local location, but make sure not to overwrite the one of <X>
  8. Navigate in Windows Explorer to the location(s) where you saved the .xsn files
  9. Rename the .xsn file-extension into .cab
  10. Extract both template.cab archives to local folders
  11. Open the folder of template for <Y>, and open template.xsf file in an editor. Lookup 'ContentTypeID' in the file, and copy the value
  12. Open the folder of template for <X>, and open template.xsf file in an editor. Lookup 'ContentTypeID' in the file, and paste the value copied from <Y>. Save the file.
  13. Make sure to reassign 'Open with' file association for template.xsf file to InfoPath Designer
  14. Double click the modified template.xsf file, and click 'Design' to open in InfoPath Designer
  15. Publish the InfoPath form to SharePoint List
Pragmatic recipe for partial InfoPath Form copy/reuse
  1. Step 1-10 as above
  2. Open the folder of template for <Y>, open in an editor the view.xsl for which you want to reuse layout from the form template of content type <X;>, and delete all content
  3. Open the folder of template for <X>, open in an editor the view.xsl that you want to reuse, select all file content for copy
  4. Paste the copied file content in the opened view.xsl of content type <Y>, and save the file
  5. Repeat this for every view in the form template that you want to duplicate/reuse
  6. Double click the modified template.xsf file, and click 'Design' to open in InfoPath Designer
  7. Publish the InfoPath form to SharePoint List

No comments:

Post a Comment