Tuesday, December 23, 2008

InfoPath 2007: Creating a Template Part

Creating a basic Template Part in Microsoft Office InfoPath 2007 is a simple process. However the rewards that come along afterwards when you have a nice library of template parts is quite nice. In this post I will give a high level walkthrough of the steps it takes so you can see yourself how easy they are to create and hopefully recognize a few of the benefits of possibly a little work upfront.
Creating a Template Part in InfoPath 2007
Open InfoPath 2007 and select to Design a Form Template
Design a Form Template in InfoPath 2007
You are given a choice to create either a complete form or a template part. Because the component you are going to create will be used in multiple forms, it makes sense to package it as a template part instead. In this example, I will create a template part for contact information since it is contained in probably half the forms I make. Even if some slight items change, using a template part will give me a good starting point.
By selecting template part, you are given a choice to create from a blank template or based on an XML document or schema. In this case we will select Blank.
InfoPath 2007 Create a Template Part
You design your form by adding the appropriate layout tables and controls to the form. It is always a good idea to begin this step with a sketched out idea of what your form will look like on paper and the data the form will collect including any dependencies or connections identified.
Similar to a complete template, you can import data from other data sources such as SQL, web services or SharePoint. In this case, I have a list of provinces contained on a centrally available SharePoint site so I will utilize that. You never know when Canada could decide to recruit a new province or territory so its important to make it easy for this listing to stay up to date. OK So maybe in this case I just hate typing so it’s easier for me to grab this information from a central listing somewhere.

After all my labels and controls have been added, I am ready to save my template part.
InfoPath 2007 Save Template Part
When you save the template part you will notice it has its own unique file extension (xtp) rather than the xsn you would see if you were saving a complete form.
InfoPath 2007 File Extension xtp for a Template Part
Now whenever I want to create a form that contains contact information, I can simply add my template part instead of recreating every single field manually. Who has time for manual recreation of common elements when there are Stanley Cup Finals or World Cup Soccer games to watch?
Below the controls listing on the task pane select the link to “Add or Remove Custom Controls…”
InfoPath 2007 Add Custom Controls
Select Template Part from the wizard screen…
InfoPath 2007 Import a Template Part
Browse to the location of your template part. If you are working on a team, then it would be a good idea to store these in a central location so as to be a library for everyone to use.
InfoPath 2007 Select Template Part for Upload
And Voila you have a new custom control available to you in the task pane.
InfoPath 2007 - Template Parts
InfoPath 2007 Template Part
Just like any other control, click and drag it onto the form to make it appear.

Depending on the complexity of your template part, you can evaluate the benefit of using template parts by comparing the length of time it takes to click and drag versus the length of time it took you to add all the controls and set up your data connection, then multiply it by the number of times you would typically have to add those fields to a form.

Print this post

1 comment:

Shirley said...

InfoPath Forms Services, which is part of Office SharePoint Server 2007, extends your reach to organisations that do not use Microsoft Office InfoPath 2007 by allowing you to fill out forms in a common browser or even a HTML-enabled mobile device. You can visit here for more information.