Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

  • Microsoft InfoPath 2010

    Customize an External List Form in InfoPath 2010

    • 8 Comments

    In this week's “5 for forms” video demo, Trey Brumley, a software design engineer in test shows how you can use InfoPath to customize the form for an external list on SharePoint that connects to a SQL Employee database through Business Connectivity Services.

    Get Microsoft Silverlight
  • Microsoft InfoPath 2010

    Debugging Sandboxed Code in InfoPath 2010 Forms

    • 13 Comments

    In this video demo, Phil Newman from the InfoPath program management team shares some tips and tricks for debugging InfoPath forms with sandboxed code on SharePoint server 2010.

    Get Microsoft Silverlight

    Here is this link to the ULS viewer tool that is used in the demo:

    Filters:

    • Process=SPUCWorkerProcess (for administrator-approved forms, filter on the W3WP process)
    • Message=Exception thrown from business logic
  • Microsoft InfoPath 2010

    Moving fields in the data source

    • 8 Comments
    As most folks figure out quickly, InfoPath doesn't support drag-and-drop of fields in the data source. There are a lot of technical reasons for this, and even a usability concern that people won't realize they can drag fields onto the form as controls if we also allowed them to drag fields around in the data source. But we've heard enough feedback that changing that has made it onto the long list of possible features for future releases. Keep the feedback coming!
     
    So how do you move fields groups in the data source?
    One way is to right-click the field or group and select "Move Up" or "Move Down". This is great for novices because it's discoverable, but it's a painful number of clicks if you're an expert who has to move a lot of fields in many forms.
     
    A trick for the keyboardist
    The fastest way to move a field or group a long distances is:
    1. Open the data source task pane
    2. Type the "F6" key
    3. Click tab until a field in the data source is highlighted in orange
    4. Use the Up/Down arrow keys to select the field you want to move
    5. Hold down the CTRL key and use the Up/Down arrow keys to move the field
     
     
    Note that this only moves the field in order, it won't move it as a child of a different group. To do that you still need to right-click the field and select "Move".
     
    Hope that helps!
    ned
  • Microsoft InfoPath 2010

    Decoding the InfoPath picture format (also Ink Picture)

    • 2 Comments

    InfoPath provides two controls which saves pictures inside the XML form (rather than linking to it). When trying to process this XML file outside of InfoPath, you will need to translate the data back into the image binary. InfoPath picture control data and ink picture control data is stored in the XML as base64 encoded data. You will need to decode the base64 picture into binary before it is usable.

    Below is a code sample in C# that will do it:

    byte[] image = Convert.FromBase64String( s );
    MemoryStream memStr = new MemoryStream();
    memStr.Write( image, 0, image.Length );
    Image img = Image.FromStream( memStr );
    img.Save( filename );

  • Microsoft InfoPath 2010

    Complex Data Validation

    • 4 Comments
    How do you test more than 5 parameters? How do you group parameters? One answer to both questions, is to have multiple validations in one statement. We'll look into these problems in detail in the case studies below.

    Case Study #1

    Problem: a form designer wants to use this logic:

    IF (State="Ohio" or State="Alabama" or State="Arizona" or State="Georgia" or State="Utah" or State="Idaho" or State="Iowa") THEN (fail...)

    Since the Validation UI only supports 5 statements, you run out of room before entering all of the tests.

    Solution: Put more than one test in a statement. If you aren't sure of the syntax, follow along.

    Enter the first three tests.

    Click [OK] to close the dialog. Notice that the syntax is displayed in this dialog:

    Click [Modify] and use this syntax.

    When you change the first column to "The expression", you will see how to refer to the field you are checking. This differs depending on if you are checking the current field or a different field. In this case, State is the selected field, so we can enter the validation like this:

    If you OK this and then come back to it, InfoPath will automatically break out the last 4 tests into separate statements. This makes it easier to see more of the conditions that are being evaluated.

     

    Case Study #2

    Problem: a form designer wants to use this logic:

    IF (State="Ohio" or State="Alabama") and TaxRate is blank THEN (fail...)

    Using just the default Validation UI, you can't group tests like this.

    Solution:  Put more than one test in a statement. Again, if you aren't certain of the syntax, enter the tests in the Validation dialog:

    Click [OK] to close. Note the syntax in this dialog:

    Click [Modify], and use the syntax shown in the Validation statements.

     

    Alternative Approach

    Another way to handle both of these scenarios is to use multiple validations:

    This will work and in some cases would be easier to follow (the 50 states could be listed and you could scroll the Validations).

    Performance may be better in one or the other, but that would depend on the logic you are validating.

    All of these statements are evaluated. There is not an implied "and" or "or" combining them. In this last example, if you were checking the "State = ...  OR TaxRate is blank", both would fail. You could check the number of errors and would get 2, even though only 1 error message would be shown (the first one).

    Jerry Thomas
    Software Design Engineer in Test

  • 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

    Adding a Data Connection to Some WebServices Cause InfoPath 2003 to Disappear

    • 5 Comments

    When adding a web service data connection to an InfoPath 2003 form template, there is a bug that will cause InfoPath 2003 to disappear if the web service’s WSDL contains a particular recursive schema construct.  The following snippet of XSD illustrates the issue:

     

    <xs:element name="RecursiveRoot">

    <xs:complexType>

    <xs:sequence>

    <xs:element name="Branch1" minOccurs="0">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="ns:RecursiveRoot " maxOccurs="unbounded" />

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    <xs:element name="Branch2" minOccurs="0">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="ns:RecursiveRoot" maxOccurs="unbounded" />

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    </xs:sequence>

    </xs:complexType>

    </xs:element>

     

    This XSD contains a recursive structure in which there is more than 1 path of recursion and the recursive root is not marked as an optional element in the XSD when referenced.  InfoPath 2003 will work with the WSDL containing this XSD as expected if both references to RecursiveRoot were optional as illustrated in the following modified XSD (changes in red).

     

    <xs:element name="RecursiveRoot">

    <xs:complexType>

    <xs:sequence>

    <xs:element name="Branch1" minOccurs="0">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="ns:RecursiveRoot " maxOccurs="unbounded" minOccurs="0"/>

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    <xs:element name="Branch2" minOccurs="0">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="ns:RecursiveRoot" maxOccurs="unbounded" minOccurs="0"/>

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    </xs:sequence>

    </xs:complexType>

    </xs:element>

     

    If you are having issues with a web service that you own, one work around to this issue with InfoPath 2003 is to modify the WSDL for your web service as shown above.  In the case that this is not an acceptable work around, or you do not own the web service, the following steps will help you work around the problem:

     

    1.      Download the WSDL file for the web service to your local machine

     

    2.      Modify the XSD in the WSDL as shown above

     

    3.      Add a Data Connection to the local version of the WSDL file

     

    If you are setting up a submit or receive/submit web service connection then the following steps are required as well to ensure that the data InfoPath submits to the web service adheres to the original schema:

     

    4.      File --> Extract Form Files to save your form template in an uncompressed format

     

    5.      Remove the modifications made to the WSDL XSD in the copy of the XSD that was added to the form template

     

    If you modify the data connection or add another data connection to this local WSDL file for a submit web service then steps #4-#5 will have to applied again.  If you expect other users to modify the design of this form template then the local version of the WSDL should be stored in a shared location that all designers have access to.

     

    This issue has been reported to the InfoPath team as occurring in the ItemLookup method of the web services that Amazon exposes (http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl).  In the case of this method, the modification that is necessary to avoid the InfoPath 2003 bug (step #2) is the following:

     

    1.       Find the BrowseNode element that contains references to other BrowseNode elements

    2.       Add minOccurs=”0” to the BrowseNode references (these occur under the “Children” element and the “Ancestors” element)

     

    Since ItemLookup is a receive only method, there is no need to modify the form template files by hand (steps #4 and #5).

     

  • Microsoft InfoPath 2010

    InfoPath 2010 Public Beta is Here!

    • 4 Comments

    InfoPath 2010 LogoThe InfoPath team is excited to announce the release of the Office 2010 and SharePoint Server 2010 public betas! For the 1st time members of the public can download InfoPath 2010. Download it now from www.microsoft.com/2010!

    Here are just some of the highlights in this new release. (For more details, see our earlier What's New in InfoPath 2010 post).

    Quick and Easy Form Design

    • Designing good looking forms has been made easier with our new page layout templates, layout tables, and themes.
    • With our new out-of-the-box rules and improved rules management UI, you can easily add rules to validate data, format your form, or perform other actions with just a couple of clicks, and without any code. 
    • Our new “quick” publish functionality allows you to publish forms in a single click (no more clicking through the Publishing Wizard every time you want to make an update to your forms!)
    • New Controls include the picture button, signature line control and person/group picker which is now available out-of-the-box in the controls gallery.

    SharePoint Integration
    Over the past 3 years of product development, we’ve made huge investments in integration with the SharePoint platform to make it much easier to build rich forms-based applications on top of SharePoint Server 2010.

    • Using InfoPath, you can now extend and enhance the forms used for creating, editing and viewing items in a SharePoint list.
    • With the new InfoPath Form Web Part, you can host your forms on portal pages without writing a single line of code. 
    • With SharePoint sandboxed solutions, forms with code can be published directly to SharePoint libraries without requiring administratror approval.
    • Richer browser forms:Bulleted, numbered, and plain lists, multiple selection list boxes, Combo boxes, Choice group and sections, and Filtering functionality are now supported in browser forms.
    • InfoPath Forms Services Administration and Management: We have invested in many improvements to make it easier to manage InfoPath Forms Services as a component of Microsoft SharePoint Server 2010. These include Powershell commandlets to automate tasks and SharePoint Maintenance Manager Rules to monitor the health of your server.

    New iconIntroduced since the technical preview, InfoPath now supports connecting to REST Web Services.

    Go download the beta now and send us your feedback using Send-a-Smile.

    Enjoy!

    The InfoPath Team

  • Microsoft InfoPath 2010

    Why doesn't InfoPath have a Password control?

    • 0 Comments

    Q: I want to create a control for entering passwords in an InfoPath form. How do I do this?

    A: InfoPath cannot guarantee the security and privacy of text entered into a password control, so it does not contain such a control.

    But Why?

    A typical password control contains features that make it hard for anyone but the user typing the password to discover what that text is. Password controls may also interact with a secure server so that the password is not sent in clear text, but is instead encrypted. Further, copying the text from a password control is not allowed.

    Because InfoPath allows files to be stored to a user’s local file system, InfoPath will the store the value typed into a field along with the XML. Additionally, InfoPath does not perform encryption of network traffic, meaning field values used as passwords will always be sent in clear text.

    But I still want a password control

    For the above reasons, we discourage using the contents of a field in an InfoPath form for entering and submitting passwords. Additionally, modifying the files used to create an InfoPath view to use the standard HTML password control (e.g. <INPUT type=”password” ID=”MyPassword”>), will not work in InfoPath. The nearest behavior that can be achieved is to format an InfoPath Text Box control to use a symbol font set, such as WebDings or WingDings so that the text being entered cannot easily be read as it is being typed.

  • Microsoft InfoPath 2010

    Associating a Custom Document Information Panel with an Office Document

    • 2 Comments

    When a custom Document Information Panel is associated with an Office document and/or template, the information needed to locate the Panel is contained in a custom XML data part stored with the document.
    I won’t go into the details of the way an Office Open XML document is structured here (needless to say there are many great resources for this on the web), but the format is basically a ZIP file with a collection of XML files that describe the contents of the word processing, spreadsheet, or presentation. Those XML files are linked to each other via logical “relationships” that define the necessary semantics (e.g. that one file contains the content for the header).

    In the terms familiar to the Office Open specification, a custom XML data part is stored at the following location in an Office Open XML document:

    Basically, the data is stored in an XML file which is logically related to the main part for that file type, and whose logical relationship is of type “customXml”.
    Now then, the other half of the definition of a custom Document Information Panel is the content of that custom XML data part. Here’s an example of the data stored in the custom XML data part for a custom Document Information Panel:

    <customPropertyEditors xmlns="http://schemas.microsoft.com/office/2006">
          <showOnOpen>
                true
          </showOnOpen>
          <defaultPropertyEditorNamespace>
                http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-21T21:12:27
          </defaultPropertyEditorNamespace>
          <customPropertyEditor>
                <XMLNamespace>
                        http://schemas.microsoft.com/office/infopath/2003/myXSD
                </XMLNamespace>
                <XSNLocation>
                        \\contoso-server\forms\assetForm.xsn
                </XSNLocation>
          </customPropertyEditor>
    </customPropertyEditors>

    This part defines the settings for the Document Information Panel by using the following four elements:

    Element Name Definition
    showOnOpen This element specifies whether the Document Information Panel should automatically be displayed when the document is opened and the first time it is saved.
    defaultPropertyEditor This element specifies which Document Information Panel template should be shown first when the Panel is made visible (either automatically or by the user).

    The contents of this element are one of two choices:
    Standard properties – this setting shows the default Office 2007 property template
    <custom XML namespace> - if the template to be shown should be a custom Document Information Panel stored with the document, its root XML namespace is stored in this element, so Office can locate and display this information automatically when the Document Information Panel is shown

    XMLNamespace The root XML namespace of the custom Document Information Panel. If this template is the one which should be shown automatically, this value is the same as the value of the defaultPropertyEditor element.
    XSNLocation The location of the InfoPath form template to be shown in the Document Information Panel. This location can be of either of the following forms:
    • File path to the InfoPath form template.
    • The URN of the form template if it is a template installed on the target computer.

    With that information defined, Office automatically locates a custom Document Information Panel and displays it as requested. Note that none of these steps involve using Office to set up the Document Information Panel – this process can be automated without Office (for example, to add a Document Information Panel to a template as part of a server-based process).

    Alnur Ali
    Program Manager

  • Microsoft InfoPath 2010

    Showing a Red Asterisk on a Rich Text Box

    • 1 Comments

    Q: How do I get the red asterisk to show on a Rich Text Box? There isn’t a checkbox for “Cannot be blank” on this type of control!

     

    A: Easy - add a declarative data validation rule for the condition where the field bound to the Rich Text Box “is blank”. To get started, display the control’s properties dialog box and then click Data Validation.

     

    So now you’re wondering – why isn’t there a simple checkbox for that?

     

    Behind the scenes, the “cannot be blank” checkbox actually maps to a change in the schema, rather than a declarative validation rule. For strings we add a length restriction, but for other types it sets nillable="true" (can be blank) or nillable="false" (cannot be blank).

     

    This explains why the checkbox is enabled when using a schema you’re creating in InfoPath and disabled when using a fixed schema from an external source. Since the schema we use for rich text (XHTML) nodes is a complex type the nillable approach doesn’t apply.

     

    So why does a declarative validation rule cause a red star to appear? When the form is running, the validation display semantics don’t distinguish between schema validation, declarative validation, and even code validation if you use an OnValidate event handler and/or add to the Errors collection. The logic for the validation display is:

     

                if( node fails validation )

                {

                            if( string value of node is blank )

                            {

                                        show red star

                            }

                            else

                            {

                                        show red border

                            }

                }

     

     

  • Microsoft InfoPath 2010

    InfoPath Forms Services and AJAX

    • 0 Comments

    There's been lots of well-deserved hype lately around Web 2.0 and the technology that's fueling it, AJAX. We're receiving lots of questions such as "do InfoPath browser forms support AJAX?". The answer is more complex than just yes :-); this article aims to clarify any ambiguities here. But first, some definitions.

    What is AJAX?

    Definition from Wikipedia: Ajax, shorthand for Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user makes a change. This is meant to increase the web page's interactivity, speed, and usability. 

    What is a postback?

    After a page has been loaded, a postback is defined as a subsequent browser request to the web server. Ajax is about asynchronous postbacks - those that allow the user to continue working with the page while the refresh happens.

    Does InfoPath Forms Services use AJAX?

    For a broad set of user actions while editing the form, there will be no postback to the server at all - way faster than an asynchronous postback – and the HTML will be incrementally updated, with no flash. This is because InfoPath Forms Services is capable of translating the declarative logic you've placed in the form into dynamic JavaScript snippets.

    Such client-side operations work for actions such as inserting and deleting sections or table rows, conditional visibility or formatting, validation errors, calculations, firing rules to modify data, etc.

    Cases where postback will occur have one thing in common: there's something that absolutely cannot be evaluated on the client, and thus has to be sent to the server for evaluation. For example:

    - there is managed code in the form which needs to run (e.g. AfterChange event)

    - there are complex XPath expressions used for a calculation, condition for a rule etc   

    When postback does need to happen it generally uses an XMLHTTP postback out-of-band; it does not involve a full page postback. The HTML can therefore be incrementally updated.

    How can I tell when the postbacks will happen?

    We'll only touch on this subject very briefly - expect more content on this soon. InfoPath Design Checker, in conjunction with InfoPath Forms Services, will provide you insights on the user actions that will cause a postback. It will also provide suggestions as to how to avoid these postbacks. Here's how to see these suggestions:

    1. Make sure that your form template is browser-enabled by going to Tools | Form Options | Compatibility, and checking "Design a form template that can be opened in a browser or in InfoPath".

    2. In the same dialog, provide a URL to a server running InfoPath Forms Services:

    3. At the bottom of the Design Checker task pane, click Options, then check the "Show Browser Optimization Messages" checkbox:

    4. Observe the postback optimization messages in the design checker task pane:

    We'll follow-up with a separate article on ways to interpret these messages, and tips and tricks around improving form postback experience.

    AJAX and forms hosted in a custom ASPX page

    You can create custom ASPX pages hosting the InfoPath form control (XmlFormView; more on it here). Everything within the form still uses the above AJAX architecture. But if you need code-behind the page to communicate between the InfoPath form and other ASP.NET controls in the page, then those events will trigger a full-page postback.

    Office Forms Services and ASP.NET AJAX framework

    In MOSS 2007, we don't offer integration with the ASP.NET AJAX framework (also known as Atlas) to allow for partial postbacks involving communication with other ASP.NET controls in the page. Another thing to note is that InfoPath XmlFormView control will not work inside an ASP.NET AJAX UpdatePanel. At this point, there is no workaround to make it work. Integration with the ASP.NET AJAX is a frequent customer request; we're carefully considering it for future releases.

    Alex Weinstein
    Program Manager
    Alexei Levenkov
    Software Design Engineer

  • Microsoft InfoPath 2010

    Download the Beta!

    • 10 Comments
    I'm super excited to announce Microsoft Office InfoPath 2007 Beta and Microsoft Office Forms Server 2007 Beta for browser-enabled forms, so you can install both of them today.
     
     
     
    After registering you'll get to select which products you want, which should include:
    • Microsoft® Office Professional Plus 2007 (includes InfoPath)
    • Microsoft® Office SharePoint® Server 2007 - Enterprise (includes Forms Services, which is also available standalone as Microsoft® Office Forms Server 2007. Both servers have 64-bit options.)
     
    All are available in English, French, Spanish, German, and Japanese, so tell your friends!
     
     
    Woohoo!
    - Ned and the whole exuberant InfoPath team
  • Microsoft InfoPath 2010

    Capacity Planning for SharePoint 2010

    • 0 Comments

    Check out the new Capacity Management Resource Center for SharePoint 2010 that went live when Office 2010 released to manufacturing last Friday, April 16th.  The InfoPath capacity planning document  along with a refresh of the Capacity Planning Tool Kit are now available.

    The Capacity Management Resource Center contains resources to help you with capacity management in your Microsoft SharePoint Server 2010 environment—map your solution design to a farm size and set of hardware that supports your business goals.

  • Microsoft InfoPath 2010

    Cool Forms! Weather Forecast Form

    • 8 Comments

    This week’s cool form displays your local weather forecast by using a REST Web Service data connection to pull in weather information from an online weather service. There are two views to the form, one minimal and one extended. The form contains linked picture controls that use rules to concatenate the Web service data and generate a URL pointing to images on the weather site. By hosting this form inside the InfoPath form Web part, you can display the latest weather forecast information on your SharePoint portal pages.

    Minimal View:

    weather_minimal

     

     

     

    Extended View:

    weather_extended 

    For more information about using REST Web Service data connections with InfoPath forms, see our earlier blog post http://blogs.msdn.com/infopath/archive/2010/02/11/add-a-dynamic-map-to-a-contact-form-using-rest-web-services.aspx.

    If you have a “cool” form that you would like to share with us, please send an e-mail with the following details to coolform@microsoft.com -

    • Attach 1 or 2 screenshots of your form
    • Provide a brief description of the form
    • You may also attach the XSN file (optional)

    The most popular submissions will be featured on our blog in future posts.

    Check out other Cool Forms here.

  • 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

    Help Us Improve InfoPath: Send Us Your Forms!

    • 11 Comments

    The Microsoft Office InfoPath Team is interested in seeing how you are using InfoPath.  We would like you to send us your InfoPath forms so we can review them and collect data on how you are using the forms.  We will be using these forms to implement improvements in future versions of Microsoft Office InfoPath. We are interested in looking at a variety of forms ranging from simple to complex (in terms of length, rules, data connections, code, etc.).

    Please send us your forms at ipforms@microsoft.com and include a brief description of how the form is used, what is working well for you and any suggestions for improvement. Also let us know if we can contact you with any follow up questions.

    We cannot guarantee that every form will be reviewed or that the confidentiality of the forms or information contained therein will be maintained.  We ask that you not submit forms containing confidential information.
     
    Thank you for your submissions.  We look forward to hearing from you.
    Microsoft Office InfoPath Team

  • Microsoft InfoPath 2010

    Do it anyway: Submitting with Data Validation errors

    • 5 Comments
    When building a workflow solution using InfoPath, it is often necessary to enforce data validation for some, but not all users. For example, in a simple expense report workflow, Employee->Manager->Accounting, the manager may be required to specify the cost category. The employee, however, can't provide this data. This means that setting the "cannot be blank" property for the costCategory field in the InfoPath form will not be enough to make this work. In this article, we will explore a technique that will let you use powerful InfoPath data validation capabilities to enforce this business logic correctly.
     
    You may have seen a different incarnation of the same problem - "if only I could submit the form with data validation errors...". If so, read on.
     
    1. Create a node in your data source that remembers the role of the current user; let’s call that node userRole. Create rules or code to get that node populated on load of the form.

      Trick 1 - acquiring user role. To set the value of a node to the current user role in rules, use the XPath expression xdXDocument:get-Role().

      Trick 2 - acquiring Active Directory username.  If you are using InfoPath 2007, you can get to the username of the current user through the built-in userName function. In InfoPath 2003, the easiest way to accomplish this is to write a simple whoAmI web service (here is a sample implementation), and plug it in to your form template through a secondary data connection.

    2. Setup data validation logic on the costCategory field by using the Data Validation dialog (not through the “cannot be blank” shortcut in the properties dialog).

    3. Add a new "logical and” clause to the data validation condition. This clause will check if the userRole actually requires the field to be filled out. The entire data validation condition will evaluate to false if the userRole doesn't have this requirement, and the error message will not be shown:
     
    This technique will work in both InfoPath 2003 and InfoPath 2007, and it is supported in browser-enabled form templates.
     
    Alex Weinstein
    Program Manager
  • Microsoft InfoPath 2010

    Using the Events Manager of the InfoPath Hosted Control

    • 6 Comments

    The InfoPath hosted control gives developers of third party hosted applications the ability to respond to events in the form.  The InfoPath event manager provides this functionality.  Through the event manager a host application can respond to 5 form events, 3 xml events and 1 control event:

    Form Events

    Xml Events

    Control Events

    Saving event
    Context Changed event
    Sign event
    Merging event
    View Switched event

    Changing event
    Validating event
    Changed event

    Clicking event

    How can third party host applications use the event manager?

    Step 1: Implement an InternalStartup method

    First, add code to handle the InternalStartup event. InternalStartup method will execute when a form loads.

    public Form1()
    {
                InitializeComponent();
    
                //sync to the startup event where you can register for individual events
                formControl1.InternalStartup += new Microsoft.Office.InfoPath.FormControl.EventHandler<EventArgs>(InternalStartup);
    }

    Next, implement your InternalStartup method. The function signature should look similar to:

    void formControl1_InternalStartup(object sender, EventArgs e)

     

    Step 2: Register to receive events

    In your InternalStartup method add code to register for events. For form events this code looks like this.

    void InternalStartup(object sender, EventArgs e)
    {           
           ((FormControl)sender).EventManager.FormEvents.ViewSwitched += new ViewSwitchedEventHandler(OnSwitchView);
           ((FormControl)sender).EventManager.FormEvents.Submit       += new SubmitEventHandler(OnSubmit);
           ((FormControl)sender).EventManager.FormEvents.Sign         += new SignEventHandler(OnSign);
           ((FormControl)sender).EventManager.FormEvents.Save         += new SaveEventHandler(OnSave);
           ((FormControl)sender).EventManager.FormEvents.Merge        += new MergeEventHandler(OnMerge);
     }

    For xml events you must provide the XPath of the node whose events you wish to respond to. Below is a sample of how to register to receive xml events.

     

    void InternalStartup(object sender, EventArgs e)
    {
          ((FormControl)sender).EventManager.XmlEvents["/my:myFields/my:field1"].Changed    += new XmlChangedEventHandler(FieldChanged);
          ((FormControl)sender).EventManager.XmlEvents["/my:myFields/my:field1"].Changing   += new XmlChangingEventHandler(FieldChanging);
          ((FormControl)sender).EventManager.XmlEvents["/my:myFields/my:field1"].Validating += new XmlValidatingEventHandler(FieldValidating);
    }

    To receive the click event for a button you must specify the control id of the button. Below is a sample of how to register to receive control events.

    void InternalStartup(object sender, EventArgs e)
    {
          ((ButtonEvent)((FormControl)sender).EventManager.ControlEvents["CTRL2_5"]).Clicked += new ClickedEventHandler(ButtonClicked);
    }
    

     

    Step 3: Implement methods to handle each event registered

    The final step is to implement handlers for the events you have registered for.
    The handlers for the events have the following method signatures.

    Form Events

    public delegate void ViewSwitchedEventHandler(object sender, Microsoft.Office.InfoPath.ViewSwitchedEventArgs e)
    public delegate void SubmitEventHandler(object sender, Microsoft.Office.InfoPath.SubmitEventArgs e)
    public delegate void SignEventHandler(object sender, Microsoft.Office.InfoPath.SignEventArgs e)
    public delegate void SaveEventHandler(object sender, Microsoft.Office.InfoPath.SaveEventArgs e)
    public delegate void MergeEventHandler(object sender, Microsoft.Office.InfoPath.MergeEventArgs e)

    Xml Events

    public delegate void XmlChangedEventHandler(object sender, Microsoft.Office.InfoPath.XmlEventArgs e)
    public delegate void XmlChangingEventHandler(object sender, Microsoft.Office.InfoPath.XmlChangingEventArgs e)
    public delegate void XmlValidatingEventHandler(object sender, Microsoft.Office.InfoPath.XmlValidatingEventArgs e)
    

    Control Events

    public delegate void ClickedEventHandler(object sender, Microsoft.Office.InfoPath.ClickedEventArgs e)

    Example: changed event, view switched event, button clicked event.

    void FieldChanged(object sender, XmlEventArgs e) {}
    void OnSwitchView(object sender, ViewSwitchedEventArgs e) {}
    void button1_Click(object sender, EventArgs e) {}

     

    Things to know about handling events

    1. Events are handled first by the form’s business logic, then by others who register to handle events. Since events are handled asynchronously it is possible that the code in the business logic may cancel the event, and deny the host the opportunity to handle the event.
    2. In order to handle the submit, save and merging events, the designer of the form template must specify that the event is to be handled through the use of code. Without enabling this in the form template the event will not be handled in code.
    3. Buttons must specify that clicks be handled through code or the event will not be handled through code.
    4. The sign event will only take place when the form is fully trusted.
    5. The Loading and VersionUpgrade events are not available from third party hosted applications as these events occur before the form is loaded in the hosted application.

    DeVere Dyett
    Software Design Engineer in Test

  • Microsoft InfoPath 2010

    Install the Office 2010 Technical Preview and win an Xbox 360 Elite!

    • 1 Comments

    We on the InfoPath team are delighted to announce the release of Microsoft InfoPath 2010 (Technical Preview). We’re really excited to share all of our great new features with you!

    (Click the thumbnails for higher-resolution images.)

    InfoPath 2010

    InfoPath Desiger 2010

    Highlights

    • Use InfoPath to customize SharePoint list forms
    • Design forms more quickly and easily with page and section layouts, themes, and Fluent user interface.
    • Add smarts to your forms with pre-built rules
    • Publish your forms with one-click

    Where do I sign up?
    The Office 2010 Technical Preview is a limited-availability release.  To sign up to be considered for the Office 2010 Technical Preview program:

    How do I win the Xbox? 

    • Build a real-world end to end application using InfoPath 2010 and Microsoft SharePoint Server 2010.
    • Download the Community Clips Recorder from http://communityclips.officelabs.com/ 
    • Record a walkthrough of your solution, showing us how you used InfoPath forms and other Office technologies (5 minutes maximum)
    • Submit the finished video to us

    Contest is limited to eligible members of the InfoPath 2010 Technical Preview program referenced above, and additional limitations may apply.  All submissions will be reviewed by the InfoPath team, and prizes will be awarded in several categories, including best overall solution, best video, and best bug.  Contest details will be posted on the technical preview site at http://connect.microsoft.com.

    We will post more details on our new features in the coming weeks. Stay tuned!

  • Microsoft InfoPath 2010

    Cool Forms! Feature Request Form

    • 0 Comments

    This week’s cool form is a feature request issue tracking list used by the Visio team. It’s divided into two main sections, the separate status section allows readers to jump directly to the information they care most about. It uses picture buttons to allow selection between ‘Office 14’ and ‘Office 15’ and to show which one is currently selected.  This form also dynamically generates the proper direct link to the bug database based on the bug ID that is entered.

    Feature Request Form

    If you have a “cool” form that you would like to share with us, please send an e-mail with the following details to coolform@microsoft.com -

    • Attach 1 or 2 screenshots of your form
    • Provide a brief description of the form
    • You may also attach the XSN file (optional)

    The most popular submissions will be featured on our blog in future posts.

    Check out other Cool Forms here.

  • Microsoft InfoPath 2010

    Save the Date! Using Horizontal Repeating Sections

    • 4 Comments
    InfoPath 2007 introduces a new flavor of the repeating section control - horizontal repeating section. It is useful when you want to present or edit repeating data in a structured format. When new items are added, they show up side-by-side with the existing items instead of one on top of the other.
     
    Horizontal repeating section is a new building block for layouts. In my previous post about horizontal repeating tables, we discussed how a horizontal repeating table is a combination of a horizontal repeating section and layout tables. You can make your own new layouts by using this new control.
     
    For example, one cool use of a horizontal repeating section is a "calendar" - style form:
     
    Play with it!
    Download the form template and try a few things (requires InfoPath 2007, and save it to your computer before opening it):
    1. Switch to a different month by using a dropdown on top of the form.
    2. Add a note for a day.
    3. Add a note with an exclamation sign (i.e. "presentation!") - notice the day turning red.
    4. Switch views to the summary view, and observe all appointments as a flat list.
    5. Open the form template in design view, and view its logic by going to Tools | Logic Inspector.
     
    How it's done
    In this form, each day in the calendar is displayed by using a horizontal repeating section; only the header ("Monday, Tuesday, Wednesday…") is static. To accomplish this, we are using several powerful tricks:
     
    1. Calendar generation is completely dynamic. To generate a view of a different month, we are setting the following fields in the form under myFields/currentMonth:
      • firstDay [date field in XML format (YYYY-MM-DD); set to the first day of the month that you want to view the calendar for - i.e. for May 2007, set to "2007-05-01"]
      • numberOfDays [integer; number of days in the month that you want to present; i.e. for May 2007, set to "31"]
      • mondayOffset [integer; weekday of first day of the month; Sunday=0, Monday = 1, Tuesday = 2, etc. I.e. for May 2007 that starts on Tuesday, set to "2"]

      Note that if you wanted to extend this calendar to show additional months, you could do so by adding rules to set these parameters for different months. It's also easy to move this logic to a web service or form code - thus eliminating the need to maintain a static list of months.
       
    2. Horizontal Repeating Sections wrap when placed inside a table. The wrapping point is determined by table width. This allows us to set up a 7-day-long week.

    3. Conditional formatting works just as expected on horizontal repeating sections. This allows us to highlight today's date, set red background for days marked with an exclamation sign, and set correct background color for weekends.

    4. Default values help us create a necessary number of instances of the horizontal repeating section to cover for the longest month, even if it starts on Saturday. We need 6 instances to cover for "blank" days before the first day of the month, plus a maximum of 31 days in a month = 37 instances. To accomplish this, you can follow the technique from this article.

    5. Rules provide a mechanism for month selection: when a month is selected from the dropdown on top of the form, correct values are set for nodes under myFields/currentMonth.
     
    Of course, there are many uses beyond a calendar, otherwise we would have just built a calendar control, but we couldn't resist sharing this example because it shows off so many tricks.
     
    Alex Weinstein
    Program Manager
  • Microsoft InfoPath 2010

    Create a Rating Control using Picture Buttons

    • 3 Comments

    In this short video demo, Matt Bielich from the InfoPath test team shows how you can add a rating control to your InfoPath 2010 forms using picture buttons.

    Get Microsoft Silverlight
  • Microsoft InfoPath 2010

    Multi-Select List Box: Requiring at least one entry

    • 2 Comments
    Yesterday I introduced the Multi-Select List Box and talked about how its data source is somewhat special: it binds to a repeating list of fields instead of a single field like the normal List Box does.
     
    When you need to ensure that at least one item is selected in the multi-select list box, you may be tempted to go to Muti-Select Listbox Properties to check the "cannot be blank" property; however, this property will not be available for multi-select list boxes because of their binding. Since a multi-select list box binds to a repeating field, what you really need is something that means "occurs at least once". Here's how…
     
    Visuals - Showing the red asterisk (*)
    1. Insert a multi-select list box and remove its border.
    2. Create a two-column layout table; place the multi-select list box into the first column of that table.
    3. Place an expression box into the second column of the layout table. Use static text * (asterisk) as the contents of the expression box and set its font color to red.
    4. Set up conditional formatting on the expression box:
          if count of elements in the repeating field is greater than 1, hide this control
    5. Set up a visible outside border on the layout table.
     
    The steps provided above will provide a visual indication to the user that the field is required - a red asterisk will be shown whenever the multi-select list box doesn't have any option checked. After you're done, you should see results similar to the following:
     
    Form Design
    Form Filling
     
    Preventing submit
    We still need to make sure that our users can't submit a form with this error - since nothing we've done above prevents form submission. This can be achieved in several ways:
     
    • Option 1: Use rules for form submission
    As the first step of submission, check if count of elements in the repeating field is less than 1. In that case, show an error message and stop processing all rules, essentially preventing form submission.
    • Option 2: Add data validation to another field
    if count of elements in the repeating field is less than 1. This will cause InfoPath to add an error to its Errors Collection behind the scenes if the condition is not met, and your users will not be able to submit the form.
    • Option 3: Write code for the Submit action
    In code you can check the condition and add elements to the Errors Collection as necessary.
     
    - Alex Weinstein
    Program Manager
  • Microsoft InfoPath 2010

    Example script for showing Mail Envelope based on User’s Role

    • 1 Comments

    The option to “Submit as Email” doesn’t include the form in the body of the mail, so here’s another way to encourage your form-fillers to send their forms as email and include that body.

    This script could be used in a Blogger form to turn on the Mail Envelope when the user switches to the “Email” view. That event could be triggered by the form-filler using the View menu, or even by a Rule on a button. It also makes some decisions based on the user’s current role so you can see how to do that.

     

    function XDocument::OnSwitchView(eventObj) {

      var mail = XDocument.View.Window.MailEnvelope;

     

      if (XDocument.View.Name == "Email") {

        // get nodes from DOM

        var blog = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:blog");

       

        var id       = blog.selectSingleNode("@ID");

        var title    = blog.selectSingleNode("@Title");

        var blogger  = blog.selectSingleNode("@BloggerName");

        var replies  = blog.selectNodes("d:reply/@ReplyName");

     

        // Set To field to include blog and the original blogger

        mail.To = "blog; " + blogger.text;

     

        // Set CC field to include all the replies (minus the current one)

        if (replies != null) {

          var cc = "";

          for (var i = 0; i < replies.length - 1; i++) {

            cc += replies(i).text + "; ";

          }

          mail.CC = cc;

        }

     

        // Set subject to look like a thread

        var subject = "Blog " + id.text + " - " + title.text;

        if (XDocument.Role != "Create")

          subject = "RE: " + subject;

        mail.Subject = subject;

     

        // Show the mail envelope

        mail.Visible = true;

      }

      else {

          mail.Visible = false;

      }

     

     

Page 6 of 12 (298 items) «45678»