Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

June, 2005

  • Microsoft InfoPath 2010

    Hiding hint text when conditionally hiding a repeating or optional control

    • 2 Comments

    Certain controls, such as repeating and optional sections and repeating tables, will display a link that, when clicked, will insert a new item into the form. By default, the text of this link, which is called hint text, is “Insert item” for repeating controls and “Click here to insert” for optional sections.  This text can be customized or turned off completely through each of these control’s property dialogs.

    In addition, the InfoPath Designer enables you to specify conditional formatting for these controls.  One of the actions that you can perform is to hide the control based on some condition.  When that condition is true, the control is hidden.  However, when the control is hidden, the hint text remains visible. This is often perceived as a bug in InfoPath but is actually by-design.

    The reason behind this is simple and makes complete sense once you understand it.  Very simply put, each of the repeating controls allows you to set conditional formatting on a per-row basis.  This means that you can specify a condition that will hide a specific row and not the entire repeating table or all instances of the repeating section.

    However, sometimes, especially in the case of optional sections, you wish to hide the entire control instead of just a single row.  The workaround for this is to put the control inside a section.  Then, set the condition which will hide the control on the section itself.  This will hide the section and all controls within it.

     

  • Microsoft InfoPath 2010

    Calling code/script from a Rule

    • 7 Comments

    Rules are a quick way to add dynamic functionality to a form, so a lot of programmers choose to use rules even when they know how to write the code to do the same thing. However, sometimes after writing a complex set of rules they may realize that they need to do something rules doesn’t support, and we know they don’t want to rewrite all their rules in code just to add that one little bit.

    Alas, there’s no rules action type for “Call code”, but there is a roundabout way to call your code anyway.

    Let’s say you have the following function in your form template:

    VBScript
    Function Test(param)
      XDocument.UI.Alert("Param: " & param)
      Test = true
    End Function
    Jscript
    function Test(param) {
      XDocument.UI.Alert("Param: " + param);
      return true;
    }
    VB.Net
    Public Function Test(ByVal param As String) As Boolean
      thisXDocument.UI.Alert("Param: " & param)
      Test = True
    End Function
    C#
    public boolean Test(string param) {
      thisXDocument.UI.Alert("Param: " + param);
      return true;
    }

     

    You can call that function from the condition of a rule by using the xdExtension namespace.

    For example, here’s how to call the function from a rule when the form is opened:

    1. Click Form Options on the Tools menu.
    2. On the Open and Save tab, click Rules.
    3. Click Add, name the rule, and then click Set Condition.
    4. Select The expression in the first drop-down list, and then enter: xdExtension:Test(“foo”)
    5. If you want the function to be conditional, then put the condition before the function call with an AND clause. For example, to get if foo>bar, then Test(“foo”), use foo>bar and xdExtension:Test(“foo”). (This is possible because conditions are evaluated using short-circuit boolean evaluation. In other words, they are evaluated one clause at a time, and if the first clause determines the result, then the rest of the conditions are “short circuited” and don’t get executed.)
    6. The Rule dialog box requires at least one action, but if you don’t have any actions to run in that rule, you can click OK if you select the Stop processing rules when this rule finishes checkbox. To avoid actually stop processing rules, make your condition always return false. For example: xdExtension:Test(“foo”) and false (“false” here is actually looking for the node named “false” which doesn’t exist, so returns the empty set, which is translated to false(). You could just as easily use “foobar” or anything else.)

    Finally, extract your form files and add the following attribute to the manifest.xsf file’s xDocumentClass element:

    xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension"

  • Microsoft InfoPath 2010

    InfoPath @ TechEd 2005 Orlando

    • 0 Comments

    We should have blogged something earlier, but we’ve been too busy getting ready for a great TechEd experience!

    InfoPath falls into the Smart Client Development track. By now, if you’re attending TechEd in Orlando next week you should already have your Breakout sessions picked out. In case you’re still waffling, the three sessions you must attend are:

    CLI235  InfoPath: Introduction to Forms Development
    Day/Time: Monday, June 6 3:15 PM - 4:30 PM Room: N 310 H
    Speaker: Edward Essey
    This session quickly runs through the many must-know development techniques that form the foundation of InfoPath 2003 development. We discuss declarative form design, rules, calculations, deployment and security levels. If you have not yet built and deployed an InfoPath solution, this session gives you the basis you need for the following advanced sessions.

    CLI333  InfoPath: Best Practices for Building Enterprise Solutions
    Day/Time: Monday, June 6 5:00 PM - 6:15 PM Room: N 220 E
    Speaker: Joshua Bell
    This is a must-attend session for developers who want to learn best practices, tips and tricks, how-tos and detailed internals of the InfoPath programming model. Sample topics covered include workflow, offline, connectivity, SharePoint products and technology integration, end-to-end solution examples, and more.

    (Repeats as CLI333R on Thursday, June 9 1:30 PM - 2:45 PM Room: S 310 E)

    CLI335  InfoPath: Developing Forms Using Managed Code
    Day/Time: Friday, June 10 9:00 AM - 10:15 AM Room: S 320 G
    Speaker: David Gerhardt
    This session focuses on InfoPath 2003's support for managed code. Learn how to start with InfoPath projects using the Toolkit for Visual Studio .NET 2003, use managed code in your InfoPath form to implement business logic, and integrate with the .NET Framework. Drill into InfoPath's XML-based programming model and best practices for InfoPath solution development with managed code, including covering issues around architecture, security and deployment.

    The three of us presenting have been working hard together to make sure our sessions cover pretty much everything you need to know to get started with InfoPath and scale up to enterprise solutions.

    In addition, we’ll have a slot at the Smart Client Development “Cabana” area to answer your questions, and we’ll be presenting several “Chalk Talk” interactive discussions. Last year we had a blast brainstorming with attendees to help architect solutions using InfoPath. John and Scott from the InfoPath team are attending as well to answer your questions, as well as Patrick from InfoPathDev.com.

    And that’s just the InfoPath team itself! If you search for other sessions talking about InfoPath you’ll find nearly a dozen Breakouts and Labs.

Page 1 of 1 (3 items)