Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

  • Microsoft InfoPath 2010

    InfoPath SP1 Hands-on Labs on MSDN

    • 6 Comments

    The final version of InfoPath Hands-on Labs has been posted on MSDN. The labs provide an overview of InfoPath 2003 and SP1 features, and are divided into the following topics:

    • Editing forms and working with form data
    • Creating forms and layout
    • Form deployment
    • Working with controls
    • Business Logic
    • Custom controls
    • Roles
    • Working with data sources
    • Working with ADO.NET DataSets
    • Digital Signatures
    • Workflow support
    • Working with custom task panes
    • Business logic using managed code
    • External automation

    All practice files and setup instructions are included with the labs. The labs require InfoPath 2003 Service Pack-1 Preview which can be downloaded from here.

  • Microsoft InfoPath 2010

    Extending the InfoPath control set with custom controls

    • 7 Comments
    InfoPath provides a rich and complete set of generic built-in controls in both 1.0 and SP-1, but there are some cases where there is a need for a control that is specific to your form or to your organization.  InfoPath SP-1 provides functionality to let users extend the set of controls available. Form developers can leverage currently existing ActiveX controls and use them within InfoPath. Also, following a few prescribed steps, software developers can write their own ActiveX controls to be used in InfoPath.

    InfoPath’s custom control support allows users to create controls for three different types of binding:

    Simple data type (string, numbers, etc)

    Controls that are written to bind to simple data types would allow a control to do custom processing on data before it gets put into the XML. The control can be designed to have UI that combines multiple simple controls (buttons, textboxes, checkboxes, etc…) to encapsulate them into one control. For example, multiple buttons can be combined with a textbox to make an in-document calculator control. Combining these all into one control will provide a simple way to re-use the same control in multiple forms.

    XML stream

    InfoPath SP-1 allows XML nodes to follow any schema. This allows form developers to work with industry standard XML Schemas. One example is a MathML control that could be written for InfoPath to save XML compliant with the MathML schema and display it in InfoPath form in a meaningful manner.

    IXMLDomNode

    For greater flexibility, InfoPath custom controls can be bound to an IXMLDomNode and any msxml operations can be performed directly on the XML tree.

    Deployment

    Custom controls need not be installed on every form users’ computer before loading the form. Controls can be packaged with your form solution so that on first open, the control will be registered and installed. Controls should be stored in a CAB files and able to self-register.

    Security

    Custom controls in InfoPath have a few security constraints to keep users safe. Firstly, all custom controls used within InfoPath require the IObjectSafety interface to be implemented and the control to be marked as Safe for Scripting and Safe for Initialization. Without these two flags, InfoPath will not load the form and will notify the user.

    In addition, for solution which have controls packaged in the form solution, it is necessary to sign the CAB files with a digital signature. When users open the form for the first time, they will be prompted on whether or not they will accept the control signed with that signature (similar to the ActiveX control dialogs you see in Windows 2k/XP).

    For detailed information on how to write a custom control for InfoPath, see Lab 06 in the MSDN InfoPath 2003 Training. (http://msdn.microsoft.com/library/en-us/odc_ip2003_tr/html/odc_INF_Lab_06.asp)

     

  • Microsoft InfoPath 2010

    Programmatic Selection in InfoPath

    • 11 Comments

    InfoPath supports two methods on the View OM object - "SelectText" for data entry controls and "SelectNodes" for structural controls - in order to enable programmatic selection.

    Data entry controls that can be programmatically selected (using View.SelectText):

    • Text Box
    • Rich Text Box
    • Date Picker

    Structural controls that can be programmatically selected (using View.SelectNodes):

    • Optional Section
    • Choice Section
    • Repeating Section (items)
    • Repeating Table (rows)
    • Repeating Recursive Section (items)
    • Bulleted, Numbered & Plain List
    • File Attachment

    Programmatically setting focus to these controls is not supported:

    • Drop-Down List Box
    • List Box
    • Check Box
    • Option Button
    • Button
    • Picture (Linked or Included)
    • Ink Picture
    • Hyperlink
    • Expression Box / Vertical Label
    • ActiveX
    • Section

    Examples:

    Steps to select rows in a repeating table using SelectNodes:

    In order to set selection extending the 1st two rows of a repeating table you can do the following steps:

    1. Insert a "repeating table" from the controls task pane

    2. Insert a "button" from the controls task pane

    3. Double click on the button control to bring up Button Properties

    4. Click on the "Edit Form Code" button

    [you may be asked to install Microsoft Script Editor if you don't already have it installed]

    5. This should bring up script.js file in Microsoft Script Editor with a function such as

    function CTRL5_5::OnClick(eventObj)

    {

    // Write your code here

    }

    6. Insert the following code inside the above function

    var nodeSelStart = XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2[1]")

    var nodeSelEnd = XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2[2]")

    XDocument.View.SelectNodes(nodeSelStart, nodeSelEnd)

    [This assumes that the repeating table is bound to my:group2. You can figure the XPath by looking at the Data Source task pane after selecting the appropriate repeating table.]

    7. Now you should be able to preview the form and verify that clicking on the button causes the expected selection. Please note that you have to have at least two rows in the table in order to select the first two rows. Otherwise you will see an error.

    Steps to select text in a text box using SelectText:

    In order to select text in a text box you can do the following steps:

    1. Insert a "text box" from the controls task pane

    2. Insert a "button" from the controls task pane

    3. Double click on the button control to bring up Button Properties

    4. Click on the "Edit Form Code" button

    [you may be asked to install Microsoft Script Editor if you don't already have it installed]

    5. This should bring up script.js file in Microsoft Script Editor with a function such as

    function CTRL2_5::OnClick(eventObj)

    {

    // Write your code here

    }

    6. Insert the following code inside the above function

    var nodeSelText = XDocument.DOM.selectSingleNode("/my:myFields/my:field1")

    XDocument.View.SelectText(nodeSelText)

    [This assumes that the text box is bound to my:field1. You can figure the XPath by looking at the Data Source task pane after selecting the appropriate text box.]

    7. Now you should be able to preview the form and verify that clicking on the button causes the expected selection.

  • Microsoft InfoPath 2010

    Introducing the InfoPath SP1 Master/Detail Control

    • 21 Comments

    Applies To: Microsoft Office InfoPath 2003 SP-1 Preview

    InfoPath SP-1 introduces a number of exciting new built-in controls.  One of which is the Master/Detail control.  After InfoPath 2003 was released, one of the most common questions on the InfoPath newsgroups was how to implement a Master/Detail type of control in InfoPath.  Although this was possible in InfoPath 2003 prior to SP-1, doing so was not easy or straightforward.  For this reason, InfoPath 2003 SP-1 now includes built-in support for the Master/Detail control.

    The Master/Detail control allows you to designate one control as a master that drives the data in another control which is called the detail.  When the user selects an item in the master, the corresponding data in the detail is displayed.

    When designing a form template in InfoPath design mode, inserting a Master/Detail control into your form is easy. There are actually two ways to do so.  The first way is to use the Master/Detail control in the Controls toolbox.  Inserting the Master/Detail control from the Controls toolbox actually inserts two controls – a Repeating Table that is designated as the master and a Repeating Section that is designated as the detail.  When you insert the Master/Detail control this way, as long as the “Automatically create data source” checkbox in the Control toolbox is checked, a simple data structure is created in the data source. This structure consists of a group node containing one repeating group node that, in turn, contains four child fields. The master and detail are both bound to the inner repeating group node. In this case, the master and detail are said to be linked by position in the tree.  This basically means that if you select the third item in the master control, for example, the data for the third item is displayed in the detail control. This enables you, for example, to build a form that contains basic customer information, such as customer name and SSN, in the master and more detailed information about that customer such as address and phone number, in the detail.

    The second way to create a Master/Detail relationship is by manually specifying which control is the master and which is the detail. Although this is a bit more difficult than choosing the Master/Detail control from the Controls toolbox it does give you more control over how the master is linked to the detail. (As mentioned earlier, one way of linking a master control to a detail control is by position. The second way to link a master to a detail is by key field. This type of linking allows you to specify a primary key/foreign key type of relationship where the value of the primary key in the master determines which detail data is displayed. This type of linking is only available when creating a Master/Detail relationship manually.)

    To create a Master/Detail relationship manually, perform the following steps:

    1. Insert a Repeating Table control. This control will act as the master. (Only Repeating Tables can act as master controls.)
    2. Open the Repeating Table Properties dialog either by double-clicking on the Repeating Table tab at the bottom of the control or by selecting the Repeating Table and then clicking on the Format | View Properties menu item.
    3. Click on the Master/Detail tab
    4. Click the “Set as master” option button and then type a name into the “Master ID” text box. This ID will be used to specify the master to link to when designating another control as the detail.
    5. Click OK to close the dialog and commit the changes to the Repeating Table properties. (At this point, you will notice that the tab at the bottom of the Repeating Table now contains the text “(master)” which designates that this control is now a master control.)
    6. Now, insert another Repeating Table or a Repeating Section control. This control will act as the detail control. (If you want to link the master to the detail by position, it is better to insert a Repeating Table or Repeating Section control that is bound to the Repeating Table you created in step 1. Link by position is the default behavior when inserting the Master/Detail from the Controls toolbox as mentioned earlier.)  If you insert a new Repeating Section control, you will want to add controls inside the Repeating Section in order to display the detail data.
    7. Open the properties dialog for the Repeating Table or Repeating Section as in step 2 above.
    8. Click on the Master/Detail tab
    9. Click the “Set as detail” option button.
    10. From the “Link to Master ID” dropdown, choose the ID that you created in step 4 above.
    11. Now, you have to specify how the master and detail are linked. By default, the master and detail are linked by position. Since we already talked about this type of linking above, click the “By key field” option button instead.
    12. In order for this type of Master/Detail relationship to work, you need to specify which field in the data source is the master key and which field is the detail key.
      1. Click on the data source button to the right of the “Key field (master)” edit box and choose the field from the master that should be used as the master key.
      2. Then, click on the data source button to the right of the “Key field (detail)” edit box and choose the field from the detail that should be used as the detail key.
    13. Click OK to close the properties dialog and commit the changes. (At this point, you will notice that the tab at the bottom of the Repeating Table or Repeating Section now contains the text “(detail)” which designates that this control is now a detail control.)

    Now, when you use your form, you will notice that when you select an item in the master, only those detail items whose detail key matches the master key of the currently selected item in the master control will be displayed. 

    Obviously, if there is no data, no details will be displayed.  InfoPath provides a nice way to deal with this situation. When walking through the steps to manually create as Master/Detail relationship above, you may have noticed the option “Copy key field from selected master when inserting detail” which is checked by default.  This option designates that when inserting a new detail item, the value of the master key of the item that is currently selected in the master control will be automatically copied to the detail key in the new detail item. This is quite convenient when creating Master/Detail data from scratch.

    As you can see, creating a Master/Detail relationship in InfoPath 2003 SP-1 is very easy and is just one of the many new features that were added in direct response to customer feedback.

  • Microsoft InfoPath 2010

    Creating a Multi-Select List Box in InfoPath SP1 Preview

    • 16 Comments

    Creating a Multi-Select List Box in InfoPath SP1 Preview

     

    While InfoPath does not include a multi-select list box control, it is possible to create one using the controls present in InfoPath SP1 Preview:

     

     

    Like all form design decisions in InfoPath, the first thing you need to do is think about the data you want to collect – how do you want the multiple selections represented in the XML saved or submitted by the InfoPath form? Additionally, do you want the selections to be determined at form design time (static), or at runtime (dynamic)?

     

    Here’s one approach that allows either a static or dynamic list of choices by including the choices – and the selection state – right in the form data.

     

    First, create a data structure as follows:

     

     

    Here are the steps to do this:

     

    1. Go to the Data Source task pane
    2. Click the Add button, and add a node named “options” of type Group
    3. Add a node under options named “option” of type Group and check Repeating
    4. Add a node under option named “selected” with data type True/False (boolean)
    5. Add another node under option named “text” (with the default properties)

     

    Note that if you want a very different data structure the rest of these instructions won’t apply directly, but they should get you started down the right path in terms of understanding how to create a complex control out of the primitives that InfoPath provides.

     

    Now you need to build the view – here’s what I came up with, showing the design-time structure:

     

     

    This is a Scrolling Region as the outer container for the control, containing a Repeating Table for the options, with a Check Box and Expression Box for each option. Here’s how you make it:

     

    1. Go to the Controls task pane
    2. Insert a Scrolling Region control, and resize it to the size you want the Multi-Select List Box control to be.
    3. Go to the Data Source task pane
    4. Drag the option group from the task pane into the Scrolling Region control; when the popup menu appears, select Repeating Table
    5. Double-click the Repeating Table indicator to show its properties
    6. On the Data tab, uncheck Allow users to insert and delete rows
    7. On the Display tab, uncheck Include header, then click OK
    8. Inside the Repeating Table, delete the text next to the check box in the first cell (which should say “Selected”), and resize the table cell so that the checkbox just fits within it
    9. Right-click the Text Box in the second cell, point at Change To and select Expression Box on the fly-out menu

    Next, tweak the layout and borders to make it look professional:

    1. Double-click the Scrolling Region indicator
    2. On the Size tab, set the Top, Bottom, Left and Right Padding to 0 px, then click OK
    3. Select Format | Borders and Shading..., click Outline, then click OK
    4. Select the Repeating Table indicator, then go to Format | Borders and Shading..., select None, and click OK
    5. Click inside the Scrolling Region – although you can’t see them, there will be several empty paragraphs. Arrow down until the blinking insertion point is in the last paragraph, then hit Backspace to erase them. (If you forget to do this you may see blank lines after the options when you preview the form.)

    Finally, if you want to make the selected options stand out clearly, you can use Conditional Formatting:

    1. Click the Repeating Table indicator, then go to Format | Conditional Formatting... and click Add...
    2. In the third drop-down, select TRUE (so the condition reads “selected” “is equal” “TRUE”)
    3. Click the Shading drop-down, and select a background color (e.g. light gray)

    At this point, the Multi-Select List Box control is ready to go – but it doesn’t have any options! Maybe those options are specified by your form’s back end data source (a database or web service). But for now, let’s assume the list is static:

     

    1. Go to Tools | Default Values
    2. Right-click on the option node, and select Add another option below; repeat this to create as many options as you need.
    3. Expand each option, select the text node, and type the option name in the Default value text box at the bottom of the dialog. (To make an option selected by default, select the selected node and then select TRUE in the Default value drop-down.)

    That’s it! Now just hit the Preview button on the toolbar to try our your new Multi-Select List Box control.

    Note: You can also create ActiveX controls that do XML data binding with the InfoPath SP1 Preview.

  • Microsoft InfoPath 2010

    Enabling Cuneiform Support in InfoPath 2003 SP1

    • 7 Comments

    Very often customers ask how they can enable Cuneiform entry in forms being deployed to their overseas customers. One of the exciting additions in the upcoming service pack is Antediluvian Syllabary support. With this feature, users will be able enter Cuneiform text naturally into the editor via an IME. InfoPath's Cuneiform support includes polyvalent logograms as well as transliteration.

    To enable this feature, you must first apply a language pack. To do this, go to Start -> All Programs -> Microsoft Office -> Microsoft Office Tools -> Microsoft Office 2003 Language Settings

    In the list of Available Languages, select "Akkadian"

    Click Add >> and then Click OK. You will need to restart InfoPath.

    This will also install all the files needed for the Voynich, Vinca, Iberic, Etruscan, Linear A (Minoan form), Linear B (Greek form), and Rongo Rongo language support. Please be aware that the default currency will be switched to zuzu and the default date format will be synodic.

    Cuneiform support is especially powerful when combined with Microsoft's Tablet platform.

    The InfoPath Team wishes you a happy April Fool's Day!

    (Picture of the InfoPath editor in Akkadian)

  • Microsoft InfoPath 2010

    Understanding the InfoPath SP1 Deployment and Security Model – An Introduction

    • 3 Comments

    A common question that was asked when people started using the initial InfoPath release was, “How can I distribute a form template to other people through email?”  In InfoPath V1, this was difficult because once you saved or published a form template to a location, it was ‘sited’ to that location.  If it was moved from that location, it would not open in the InfoPath Editor. 

    In the InfoPath Service Pack 1 release, it is now possible for form templates to be opened from locations other than their published location.  There is also a ‘Send Form as Attachment’ option under the File menu which attaches your form template to an Outlook mail message for distribution.  However, for security reasons, there are still limitations on what kinds of form templates can be opened and from what locations.  The following is a guide to understanding the InfoPath SP1 Deployment and Security Model:

    Form Template Security Level

    Each Form Template made in InfoPath SP1 has one of three security levels specified; Restricted, Domain, or Full Trust.  This setting is determined automatically by default, but can be set manually, if desired. 

    NOTE:  To access this setting in the Designer, navigate to Tools | Form Options à Security Tab. 

    Restricted – The form template does not allow any access outside of the form  

    Domain – The form template allows access outside of the form, but only within the domain of the form template

    Full Trust – The form template can access files and settings on the local computer

    The Full Trust security level can only be set manually by the user for installed templates or certificate-signed templates.  The maximum trust level that can be set automatically by InfoPath is Domain.

    All new blank form templates (except for Managed Code solutions) start out at the Restricted security level.  As you build the form, adding any of the following will automatically raise the security level to Domain:

    • Task Pane
    • Script
    • ADO Query or Submit Adapter
    • Web Service Query or Submit Adapter
    • SharePoint Query or Submit Adapter
    • Query to linked XML file
    • HTTP Submit
    • ActiveX Control
    • Roles
    • DLL Resource File
    • HWS
    • Rule that opens a new document 

    Opening the Form Templates in the InfoPath SP1 Editor

    The reason to make a distinction between Restricted and Domain security was to allow for form templates without script or data connections to be opened from anywhere.  Therefore, email deployment of restricted form templates in SP1 is easy, just send out the form template and it can be opened either from the Outlook mail itself or from wherever the recipient saves it. 

    With Domain form templates, some of the same security restrictions from v1 still exist, but SP1 allows for some added functionality.  Domain form templates still require that they be opened from their published location.  However, by using the Send Form as Attachment option in the file menu, a Domain form template can be mailed out as an attachment.  This attachment, when received and opened, functions as a link to the actual published location.  The form template at that publish location is what actually gets opened in the InfoPath Editor, not the one that was clicked on.  At that point as well, the published form template is copied locally and will appear as a selection in the Fill Out a Form dialog every time you launch InfoPath.

    Future Considerations

    This posting is meant as an introduction and does not cover all aspects of Deployment and Security.  If there are any specific questions, please respond via feedback to this article and I will follow up with further entries that will address more specific functionalities and scenarios.

  • Microsoft InfoPath 2010

    How can you store the result of an InfoPath expression box?

    • 0 Comments

    Question: How do I store the result of an InfoPath expression box?

    Answer: with InfoPath 2003 SP1 you can use the new calculations feature.  With InfoPath 2003, you can write script.

    The expression box control is display only, so whatever expression you end up concocting to render on the screen is neither stored in the XML nor accessible for manipulating elsewhere.  You might want this expression value to be stored in the XML, especially if you want to promote this value into a SharePoint form column.

    In InfoPath SP1, rather than using an expression box, you can set the default value for a field element to be a calculated value.  If the field is in the view, bring up the property dialog for the control associated with the field.  If the field isn't in the view, you can go to the data source and bring up the properties for the field there.  Note the fx button next to the default value.  Click that to bring up a dialog for creating a calculation.  This expression will be recalculated as needed and stored in the field.

    To do the same thing in script, download the InfoPath SDK and look into the calculations sample.  Go to this page for more information: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkAboutTheCalcForm.asp (along with a discussion of the script).

  • Microsoft InfoPath 2010

    InfoPath SP1 Preview Form Definition File Schema

    • 1 Comments

    With InfoPath 2003 SP1, there is a new schema for the form definition (.xsf) file, to match the features added to InfoPath. 

     

    There will be a documented roll-out of this schema, along with other InfoPath technical information, when the SP1 is officially released, but for those wanting to get a hold of the raw XSD file now, you can download the following:

     

    xsfschema.zip

     

    (contains xsfschema.xsd.)

     

    Disclaimer: as this schema is the InfoPath 2003 SP1 Preview schema, it is not guaranteed to be final, and might change between now and the official release of InfoPath 2003 SP1.

     

  • Microsoft InfoPath 2010

    Microsoft Office InfoPath 2003 Technical FAQ and the InfoPath Viewer

    • 6 Comments

    Looking for some of our answers to questions we get a lot?  Pull up the Microsoft Office InfoPath 2003 Technical FAQ - if you don't find the answer you need in the FAQ, please ask your question on the newsgroup microsoft.public.infopath where MVPs, experienced InfoPath users, and Microsoft InfoPath team members can all help.

    One question that comes up often regards a no-cost InfoPath Viewer.  Here are three Q&A's in the FAQ worth pointing out:

    Q. Do employees need to have InfoPath installed on their PCs in order to fill out forms created with InfoPath? Is InfoPath required for viewing or reading an InfoPath form?

    A. Information workers will need to have InfoPath 2003 installed on their PCs to enter information into InfoPath forms and to take advantage of the rich client functionality such as structural editing, business-logic validation, rich-text formatting, AutoCorrect, and spell-checking. That said, you can read an InfoPath form that has been saved to .MHT in your browser or within an HTML-enabled e-mail client, as the body of your mail message. Because InfoPath generates XML belonging to any customer-defined schemas, other software could be used to reuse and display that XML document.
     
    Q. How do users fill out an InfoPath form if they do not have InfoPath?

    A. In order to fill out forms created in InfoPath and to take advantage of InfoPath’s rich-client functionality, data validation and offline capabilities, users will need a copy of InfoPath installed on their workstation.

    It is possible to build browser-based solutions based on InfoPath forms. For example, you can build a solution in InfoPath (building a schema and Web services) that can be used for collecting information within the firewall, then use the same schema and Web services for building an ASP.NET solution for collecting information outside the firewall. For business solutions that require a “reach” (browser-based) solution, yet still use the power of InfoPath for the parts of the process that occur within an organization (where InfoPath can easily be deployed), there are two options:

    • Use ASP.NET forms in the solution to front-end the process. Data is gathered in the browser-based forms, then moved into the InfoPath forms where available. This combines the reach experience for initial data collection and the rich experience of interacting with that information via InfoPath. Customers can use the same schema and Web services for both the InfoPath and ASP.NET solutions.
    • Work with one of the many partners that have developed solutions based on InfoPath including Sourcecode, Teamplate, Ultimus and Cardiff.

    Q. Do I need to touch every desktop to deploy InfoPath? Can you host an InfoPath form in the browser?

    A. In order to fill out or design an InfoPath form, InfoPath needs to be installed on the desktop. However, once you have deployed InfoPath, you can easily roll out the form templates that users need to use InfoPath. InfoPath provides transparent deployment and maintenance of solutions via a Web-like model that downloads solutions on demand. InfoPath form templates are downloaded silently and seamlessly to the client when a user clicks on a link to an InfoPath form or clicks on an InfoPath attachment.


    A process to create an InfoPath Viewer experience if read-only is all you want: note that if you just want to be able to have a read-only rendering of an InfoPath form beyond what InfoPath can generate directly (save as MHT or via an email body), you should take a look at the SDK downlevel tool (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkUsingTheDownLevelTool.asp ) which provides a way to modify your form XML to pull in a stylesheet to use for rendering the form when InfoPath is not on the user's machine.

     

  • Microsoft InfoPath 2010

    Create dependent drop-down / list-box in InfoPath using filters

    • 11 Comments

    Summary

    Suppose you want to have the items listed in a drop-down be dependent on the selection of another drop-down (this is also known as "cascading dropdowns). If you have InfoPath Service Pack 1 installed, you could use the "Filter Data..." feature to accomplish this.

    Example

    Picture of two drop downs - state and city. 

    You have one drop down labeled "State:" with the names of states and another drop-down labeled "City:" which gets populated with the names of the cities for the state you selected on the previous drop down.

    The city drop-down obtains its values from an xml file which might look something like this:

    <Cities>
      <City state="Washington">Redmond</City>
      <City state="Washington">Seattle</City>
      <City state="California">Los Angeles</City>
     
    <City state="Florida">Orlando</City>
    </Cities>

    Implementation

    1. In design mode, right click on the "City" drop down and open the Drop-down Properties dialog.
    2. Select to Look up values in a data connection to a database, Web Service, file, Share Point library or list.
    3. Click Add and follow the wizard to add the xml file containing the city data.
    4. After completing Data Connection Wizard, in the Entries field- select the source for the drop-down values by clicking the button on the right of the field. The Select a Field or Group dialog will appear, for this case you will select the "City" repeating group.
    5. Create a Filter by clicking the Filter Data... button and clicking Add... in the Filter Data dialog.
    6. You will want to create a Filter that displays the data in which the "state" attribute is equal to the field corresponding to the "State:" drop-down (Remember that the field value is kept in the form's "Main" data source)  

     Additional Notes/Tips  

    • Previous City selection will persist after changing state. You’ll need to set a Rule to change cities to empty after a change is made to states to avoid selected city remaining in City drop down. (Right click the "State" drop-down in design mode and open the Propeties dialog, click the Rules button and create an Action to set the "City" field value to empty, no condition is necessary since this rule will apply when a change is made). 
    • Instead of using drop-down controls you could also use list boxes. 
    • You could also use Conditional Formatting to disable the "City:" drop-down until a state is selected. 
    • If you'd like to implement dependent dropdowns in a browser-enabled form template, take a look at this article.
  • Microsoft InfoPath 2010

    Sample form for "Code sample to change depth of recurring fields"

    • 1 Comments

    Here's a form sample for the article Code sample to change depth of recurring fields that let's you play with the promotion / demotion:

    MovingRecursiveSections.zip

    (This requires InfoPath 2003 SP1 ; to try the form, you'll need to open it in the designer and either republish it or just run Preview.)

     

  • Microsoft InfoPath 2010

    Code sample to change depth of recurring fields

    • 1 Comments

    TRICK: Changing the Depth of Recurring Fields

    Applies to: Microsoft Office InfoPath 2003 SP1

    Summary

    You can use the following script for promotion and demotion of recurring nodes in single depth recurrences.  (This does not work in the case of a*/b/a*…).  To work in your code, simply change the names of the parameters at the top and attach this code to events in your form code.

    SP1 Feature Usage

    Schema recurrence

    Form Code

    The following form code is written in JScript. 


    // **** PARAMETERS ****
    // Change these parameters to work with your XSD
     
    // The name of the recurring node
     
    var g_fRecurringNodeName = "my:section";
     
    // The name of the non-recurring node immediately after the recurring node (if none, set to null)
     
    var g_fNextNonRecurringNodeName = "my:HwsComments";
     
     
    // **** FUNCTIONS ****
     
    // Promotes the node up a level.
    // if fAdoptRightSiblings is true, oNode's succeeding recurring siblings become its children.
    // else these siblings stay with their parent (they reorganize in the view)
    function PromoteNode(oNode, fAdoptRightSiblings)
    {
          if(!IsRecurringNode(oNode))
          {
                alert("Promote Section - the argument is not a recurring node.");
                return;
          }
         
          // do not promote if parent is not a recurring node
          if (GetDepth(oNode) == 0)
          {
                alert("Cannot promote - this is already at the top level.");
                return;
          }
         
          // if adopting, move the succeeding siblings to be the children of oNode
          if (fAdoptRightSiblings)
          {
                while (oNode.nextSibling && IsRecurringNode(oNode.nextSibling))
                {
                      var oBefore = (g_fNextNonRecurringNodeName) ?
                            oNode.selectNodes(g_fNextNonRecurringNodeName) : null;
                      oBefore = (oBefore) ? oBefore[0] : null;
                      if (!oBefore)
                      {
                            oNode.appendChild(oNode.nextSibling.cloneNode(true));
                      }
                      else
                      {
                            oNode.insertBefore(oNode.nextSibling.cloneNode(true), oBefore);
                      }
                      oNode.parentNode.removeChild(oNode.nextSibling);
                }
          }
         
          // Move oNode up a level
          if (oNode.parentNode.nextSibling)
          {
                // has siblings
                oNode.parentNode.parentNode.insertBefore(oNode.cloneNode(true), oNode.parentNode.nextSibling);
                oNode.parentNode.removeChild(oNode);
          }
          else
          {
                // no siblings
                oNode.parentNode.parentNode.appendChild(oNode.cloneNode(true));
                oNode.parentNode.removeChild(oNode);
          }    
    }
     
    // Demotes the node down a level
    function DemoteNode(oNode)
    {
          if(!IsRecurringNode(oNode))
          {
                alert("Demote Section - the argument is not a recurring node.");
                return;
          }
         
          var oPrevious = GetPreviousRecurringNodeSibling(oNode);
          if (!IsRecurringNode(oPrevious))
          {
                alert("Cannot demote - this recurring node does not have a previous sibling recurring node.");
                return;
          }    
     
          // move the node down a level
          //   ...by making it the last recurring child of the previous sibling
          var oBefore = (g_fNextNonRecurringNodeName) ?
                oPrevious.selectNodes(g_fNextNonRecurringNodeName) : null;
          oBefore = (oBefore) ? oBefore[0] : null;
          if (oBefore)
          {
                oPrevious.insertBefore(oNode.cloneNode(true), oBefore);          
          }
          else
          {
                oPrevious.appendChild(oNode.cloneNode(true));
          }
          oNode.parentNode.removeChild(oNode);     
    }
     
    //Returns the depth of the recurrence as an integer.  If this is the top level, returns 0.
    function GetDepth(oNode)
    {
          if (!IsRecurringNode(oNode))
          {
                alert("GetDepth - the argument is not a recurring node");
                return;
          }
          var nCount = 0 ;
          while (IsRecurringNode(oNode.parentNode))
          {
                nCount++;
                oNode = oNode.parentNode;
          }
          return nCount;
               
    }
     
    // Is the particular node a Recurring Node?
    function IsRecurringNode(oNode)
    {
          if (!oNode) return false;
          return (oNode.nodeName == g_fRecurringNodeName);
    }
     
    // Finds the first preceding sibling that is a recurring node.
    // This function is for choices and mixed content.
    function GetPreviousRecurringNodeSibling(oNode)
    {
          if (!oNode) return null;
          while (oNode.previousSibling)
          {
                oNode = oNode.previousSibling;
                if (IsRecurringNode(oNode)) return oNode;      
          }
          return null;
    }
     
  • Microsoft InfoPath 2010

    Difference between an InfoPath Form and InfoPath Form Template

    • 1 Comments

    What's the difference between a form and a form template?

    We've had some people ask us about the difference between a form and a form template. It's easy to confuse the two--partly because people often expect them to be the same thing, and partly because of how we use the terms in InfoPath.

    When you design a new form in InfoPath--say, a status report for your department to fill out, you're actually creating a form template. This is the file that defines the data structure, appearance, and behavior of the forms that your users fill out. The form template usually has an .xsn file name extension, and actually consists of several files that have been compressed into one, including one or more XML schemas, an XSLT file for each view in the form, an XML file for the default data, script files or managed code assemblies, and a form definition file (manifest.xsf), which contains information about the components of the form, including how it looks and acts, deployment settings, and data connections.

    After you finish designing the form template, you can publish it so the people in your department can start filling in their status reports. As you might've guessed, each of their status reports is a form. That form is just an XML file that contains the data (and only the data) that's been entered into the form. All the other stuff that makes up the form--the graphical interface, the validation, the data connections--is provided by the form template. Which means that whenever you open a form in InfoPath, that form needs to locate and use the form template to function properly. (Otherwise, you'd just be looking at plain XML data.) To link the form to the form template, InfoPath includes a processing instruction in each form that points to the associated form template. (For those of you wondering how this works when you're offline: When you use a form, the form template is cached on your computer.)

    One last note, for the pathologically curious: For a variety reasons, we often use the term "form" to mean both forms and form templates. For example, there's a  Fill Out a Form command and a Design a Form command on the File menu. We tried using "form template" whenever discussing the .xsn file, but we discovered that the term actually confused more people than it helped. It turns out that people were much more likely to think of what they were designing as a form, instead of a form template. This stems most likely from paper forms, which are always called "forms," whether they're being designed, printed, or filled out. Also, in some cases, it was hard to draw a distinction between forms and form templates: Should the Form Options dialog box be titled Form Template Options, because you access it in design mode, or Form Options, because the choices affect how the forms will look? Finally, a hard and fast rule can make things pretty awkward: Instead of the Design This Form command, for example, we'd have Design the Form Template Associated With This Form.

  • Microsoft InfoPath 2010

    Tip to improve an InfoPath form's appearance

    • 0 Comments

    Improved InfoPath Form Look and Feel

    Apples to: Microsoft Office InfoPath 2003 and Microsoft Office InfoPath 2003 SP1

    Looking for simple ways to jazz up your form layout?

    Summary

    Using tables, inline images, background colors, and conditional visibility, I created a pretty simple look and feel that groups parts of the UI together that goes a little beyond just borders.

    Example

    Picture of an improved look for an InfoPath form 

    Implementation

    I started by drawing a rounded rectangle in mspaint, then I cut it into smaller images and added it to a table.  For the vertical part which grows, I didn’t use an image, I instead colored the background the same as the image.  Otherwise I couldn’t get it to grow when nested repeating elements would resize.  I removed all borders, padding, and other spacing to get everything to fit together.

    For the repeating section, I used conditional visibility on section with two separate images.  I had to use the following expression to get count and position for repeating sections:

    // count                                    //position

    count(../../my:SummaryItem) != count(../preceding-sibling::node()[local-name() = "SummaryItem"]) + 1

     

  • Microsoft InfoPath 2010

    Manually setting the default print margins for an InfoPath form

    • 1 Comments

    This tip applies to form designers who want to change the default print margin on a form using InfoPath 2003 since the Service Pack 1 release allows designers to change these properties in design mode from the View Properties dialog.

    So, if you do not have the Service Pack 1 installed you can still accomplish this by following these steps:

    1. Open the form you want to modify in design mode
    2. From the File menu, chose Extract Form Files…
    3. Save the document to a folder of your choose. A new, empty folder will allow you to find files easier.
    4. Locate the folder where you save the files.
    5. Right-click on the file manifest.xsf and choose Open-With…Notepad
    6. There will be an <xsf:view> element for each view. Locate the view you would like to define margins for.
    7. Insert the following XSF definition for margins (the view elements will already exist):

    <xsf:view ...>

    <xsf:printSettings

    marginUnitsType="in"
    leftMargin="0.25"
    topMargin="0.5"
    rightMargin="0.25"
    bottomMargin="0.5">

    </xsf:printSettings>

    <xsf:view>

    1. Save and close manifest.xsf
    2. Right click again on manifest.xsf and choose Open in Design Mode…
    3. From the InfoPath design mode, Publish your form so that users can print using your new margins!

    Notes: marginUnitsType can contain either in or cm. The rest of the margins are interpreted based on those unit types.

  • Microsoft InfoPath 2010

    InfoPath File Attachment Control

    • 21 Comments

    File Attachment Control

    Applies to: Microsoft Office InfoPath 2003 SP1

    Microsoft Office InfoPath 2003 SP1 introduces a number of new controls.  One of these new controls, the file attachment control, enables you to insert files which will be encoded and saved with the form. This control opens up a number of new scenarios not easily possible before SP1. 

    For example, let’s say that you have created a form that will be used by your sales people in the field. Typically, your sales people may track large amount of sales data in an Excel spreadsheet which includes fancy charts and pivot tables.  When these sales people report their quarterly earnings, you would like them to fill out an InfoPath form so that you can gather data such as total sales per region.  However, since the sales people have already gathered all the detailed sales data in an Excel spreadsheet, you don’t want them to have to reenter the data into the InfoPath form.  Instead, your sales people click on a file attachment control and attach the spreadsheet containing their sales data.  Later, when you are reviewing the data in the InfoPath form, you can double-click the spreadsheet file and open it in Excel in order to view the detailed sales data.

    Adding a file attachment control to a form is easy.  Just follow these four basic steps:

    1. Start InfoPath and design a new blank form or design an existing form.
    2. Open the Controls task pane by clicking on the Controls link in the Design Tasks pane.
    3. Look for the File Attachment control under the File and Picture category of the Controls task pane.
    4. Insert the file attachment control by clicking on it or dragging and dropping it into the view.

    Now, when you preview the form or fill out a form based on this form template, users can attach files to your form.  Also, if you open a form that has existing file attachments, you can double-click on the control to open it.  When opening files that are already attached, by default, the application that is associated with that file’s extension on your system is opened in order to view the file.

    Security

    For security reasons, not all types of files can be attached to a form.  The last thing you want is for somebody to attach a malicious executable file that formats your hard drive.  For this reason, InfoPath blocks certain file types from being attached (e.g., .exe, .com, .bat, etc.).  To determine the types of files that are considered unsafe, InfoPath follows a similar model as Outlook which is documented in http://support.microsoft.com/default.aspx?scid=kb;EN-US;290497.

    In addition to the list of file types blocked by default, you can further restrict the types of files you want users to attach to your form.  To do so, perform the following:

    1. Follow the steps above to insert a file attachment control into the view.
    2. Double-click on the file attachment control that you just inserted into your form in order to open the properties dialog for the control.
    3. On the Data tab of the properties dialog, check “Allow the user to attach only the following file types” option.
    4. In the textbox below this option, enter the extension or extensions of the file types that you want your users to be allowed to attach to the form.  Use semi-colons to separate multiple file extensions (e.g., doc; ppt; xls).

    Technical Details

    Upon attaching a file, InfoPath first builds a header structure which includes information about the file being attached. The structure consists of the following:

    ·         BYTE[4]: Signature (based on the signature for PNG):

    (decimal)                       199       73         70         65
    (hexadecimal)                C7        49         46         41 
    (ASCII C notation)          \307      I           F          A 

    The first byte is chosen as a non-ASCII value to reduce the probability that a text file may be misrecognized as a file attachment.  The rest identifies the file as an InfoPath File Attachment. 

    ·         DWORD: Size of the header

    ·         DWORD: IP Version

    ·         DWORD: dwReserved

    ·         DWORD: File size

    ·         DWORD: Size of file name buffer

    ·         File name buffer: variable size

    After building the header structure described above, the header and file data are concatenated and base64 encoded.  This base64 data is then stored with the XML data in the form.  (More information about base64 encoding can be found here: http://www.w3.org/Protocols/rfc1341/5_Content-Transfer-Encoding.html.) 

    If you wish to write code to work with InfoPath file attachments, the .NET framework provides a Convert class that includes methods to encode and decode base64 data (e.g., Convert.FromBase64String). These methods can be used to decode existing InfoPath file attachment data or to encode a file for storing in an InfoPath form.

    When a file attachment control is inserted into an InfoPath form, the following processing instruction is inserted into the XML template for the form:

    <?mso-infoPath-file-attachment-present?>

    This processing-instruction is added as a convenience for InfoPath but is not meant to be a security feature. If this processing-instruction is removed, when users fill out the form, all file attachment controls will be disabled.

  • Microsoft InfoPath 2010

    InfoPath Trick to Localize a form in a single view

    • 4 Comments

    TRICK: Localized form in a single view

    Applies to: Microsoft Office InfoPath 2003 SP1

    Need the same form in many languages?  Here’s a trick that’s easier than multiple views.

    Summary

    By taking advantage of new SP1 features, there’s a simple way to create a multi-language view without duplicating bindings.

    I have used a secondary data source with read-only borderless fields as labels for the view.  This secondary data source is populated by an XML File Data Connection that grabs a file in the LabelsLanguage form library.  This form lib populates a drop-dom, changes of this update the aux-dom and refresh the view.

    There are 2 buttons for adding new languages and editing the current labels of the form.  These pop up a second solution.  To add a new language, just fill out the form and submit.  Look at one of the existing languages for examples.  If you see a typo in your language, feel free to correct it and save.

    To work with button labels, manually update the view using xsl:value-of elements.  Otherwise, use the workaround that I have in the screenshot.

    Known issues:

    • If you update a language on the fly, you need to force IE to always update the cache so you will get the drop-down changes.
    • Some flashing when changing the language.

    Example

    Here’s a sample of what it might look like:

    Picture with a language drop down selection 

    Form Code


    public void ChangeLanguage(DataDOMEvent e)
    {           
          if (e.IsUndoRedo) return;
          if (e.Operation.ToUpper() == "DELETE") return; //handle double notifications
     
          // Generate the new file name from the drop-down
          string strFileName = (string)e.NewValue; //from dropdown english.xml
          XMLFileAdapter2 xfaLabels = e.XDocument.DataAdapters["Labels"] as XMLFileAdapter2;
          string strCurrentUrl = xfaLabels.FileURL; //from adapter http://server/site/francais.xml
          string strBaseUrl = strCurrentUrl.Substring(0,strCurrentUrl.LastIndexOf("/")); // http://server/site
          string strCurrentFileName = strCurrentUrl.Substring(strCurrentUrl.LastIndexOf("/")); // francais.xml
          string strNewUrl = strBaseUrl + "/" + strFileName;          // http://server/site/english.xml
          xfaLabels.FileURL = strNewUrl;
     
          // the drop-down refreshes everything
          xfaLabels.Query();
          (e.XDocument.DataAdapters["Languages"] as SharepointListAdapter).Query();
    }
     
    public void AddLanguage(DocActionEvent e)
    {
          string strLanguagesFormUrl = "http://your-forms-url/template.xsn";
          thisApplication.XDocuments.NewFromSolution(strLanguagesFormUrl);
          (e.XDocument.DataAdapters["Languages"] as SharepointListAdapter).Query();
    }
     
    public void EditLabels(DocActionEvent e)
    {
          XMLFileAdapter2 xfaLabels = e.XDocument.DataAdapters["Labels"] as XMLFileAdapter2;
          thisApplication.XDocuments.Open(xfaLabels.FileURL, 1);     
    }
     
  • Microsoft InfoPath 2010

    Problems Attaching a Debugger to the SP1 Preview?

    • 2 Comments

    In the feedback to "The InfoPath 2003 SP1 Preview", Laurent Kempé writes "I downloaded since a while, really cool, except that I can't attach the debugger."

     

    Here's a work around to consider:

    One of the common problems that prevents the debugger to attach is the existence of a .NET Framework newer than 1.1, for example the Whidbey Preview. InfoPath host will use the latest runtime but VS.NET 2003 can’t debug on it. One workaround against this problem is to enforce loading version 1.1 of the CLR runtime. This can be done by creating an InfoPath.exe.config file in the setup directory and specifying there the supported runtime version, something like:

     

    <configuration>

                <startup>

                            …

                            <supportedRuntime version=”v1.1.4322” />

                </startup>

    </configuration>

     

  • Microsoft InfoPath 2010

    Philo's WebLog post on "Why Smart Clients?"

    • 3 Comments

    Why Smart Clients? was posted yesterday and provides a nice perspective of the benefits of having such a smart client like InfoPath.

  • Microsoft InfoPath 2010

    How to Enqueue Submits While Offline

    • 12 Comments

    How to Enqueue Submits While Offline

    Applies to: Microsoft Office InfoPath 2003 SP1

    Scenario:

    User fills out forms for a particular form template while the laptop is disconnected from the network.  Upon reconnection, seamlessly syncrhonize the offline forms to a Windows SharePoint Services form library. 

    Solution:

    Using OnSubmitRequest, you can have the code save to the offline folder depending on if we're offline or not, as in the following code, which is written in C# using our Visual Studio .NET Toolkit.  You will also need to add a project reference to System.Xml.dll and the using System.XML; directive to your form code.

      public void OnSubmitRequest(DocReturnEvent e)

      {
     
        if (thisApplication.MachineOnlineState == XdMachineOnlineState.Online)
        {
         // submit to Sharepoint using DAVAdapter
         (thisXDocument.DataAdapters["Submit to Sharepoint"] as DAVAdapter).Submit();
        }
        else
        {
         // We are offline or working offline.
         XmlDocument oDOM = new XmlDocument();
         Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMDocument oWrappedDOM = thisXDocument.DOM;
     
         oDOM.PreserveWhitespace = true;
         oDOM.LoadXml(oWrappedDOM.xml);
         oDOM.Save("C:\\Submit\\Form_"
                + DateTime.Now.ToString("yyyy.MM.dd_HH.mm.ss.ff") + ".xml");
        }
      
        e.ReturnStatus = true;
      }
     

    Then, if you've been offline for a while and a number of files have built up, you can run the following jscript to invoke InfoPath externally and force a submit looping through the files, as below:

     
    var oFileSys = new ActiveXObject("Scripting.FileSystemObject");
    var oSubmitDir = oFileSys.GetFolder("C:\\Submit");
    var oFilesInSubmitDir = new Enumerator(oSubmitDir.Files);
     
    var oApp = new ActiveXObject("InfoPath.Application");
     
    var fso = new ActiveXObject("Scripting.FileSystemObject");
     
    for (; !oFilesInSubmitDir.atEnd(); oFilesInSubmitDir.moveNext())
    {
     var strFileName = oFilesInSubmitDir.item().Name.toLowerCase();
     
     if (strFileName.length >= 4
         && strFileName.lastIndexOf(".xml") == (strFileName.length - 4))
     {
      try
      {
       var oDoc = oApp.XDocuments.Open(oFilesInSubmitDir.item().Path);
       oDoc.Submit();
       oDoc.View.Window.Close();
       
       var f = fso.GetFile(oFilesInSubmitDir.item().Path);
       f.Delete();
     
      }
      catch (e)
      {
       WScript.echo("ERROR: " + e.description);
      }
     }
    }
    oApp.Quit();
     
     
  • Microsoft InfoPath 2010

    The InfoPath 2003 SP1 Preview

    • 15 Comments

    Do you know about the InfoPath 2003 SP1 Preview release? There are actually two free downloads available:

    1. The InfoPath 2003 SP1 client: new features and improvements added to the InfoPath client.
    2. The InfoPath 2003 Visual Studio toolkit: this provides the ability to write .NET managed code business logic in your InfoPath form.

    Anyone can download and install this version of InfoPath and use it until it expires.

    When the Office System 2003 SP1 is released (mid-2004), InfoPath will be updated to have many new features, in addition to performance improvements and bug fixes (and if you just want the performance improvements and bug fixes, the new features can be turned off).  The SP1 is completely backwards compatible with InfoPath 2003.

    This preview gives you a chance to try out an initial version of the SP1 bits now so that you can learn the new features and plan for the SP1 deployment within your company.

    The SP1 release is very important in that we were able to address customer wishes.  Give it a try!  We're certainly excited about it and will be posting about InfoPath SP1 here often (and we'll make it clear when a post is SP1 specific).

  • Microsoft InfoPath 2010

    Welcome to the InfoPath Team Blog

    • 7 Comments

    Welcome to the InfoPath team blog here at http://blogs.msdn.com/infopath/

    The InfoPath Team is looking forward to posting a variety of topics for our InfoPath users, including:

    • Feature highlights.
    • Code snippets.
    • Our best practices.
    • Tips 'n Tricks.
    • Common work-arounds.
    • Show how to leverage other Microsoft technology with InfoPath.  

    We're super-excited about InfoPath and look forward to helping our customers realize the most they can out of our new Office System 2003 application.

    Please leave some feedback if there are areas you'd like to see us cover (and please remember the community support via the microsoft.public.infopath newsgroup!).

Page 12 of 12 (298 items) «89101112