Inserting Optional Section - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Inserting Optional Section

Last post 08-22-2008 04:28 PM by Hilary Stoupa. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-20-2007 08:41 AM

    Inserting Optional Section

    I am trying to have a button that inserts an optional section.  I found code online to do this in either VB or C#.

    this.CurrentView.ExecuteAction(. ActionType.XOptionalInsert, "OptionalSection")

    I am wondering if any one knows the equivalent of this in JScript? 


  • 01-03-2008 08:25 AM In reply to

    Re: Inserting Optional Section

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-23-2008 07:13 PM In reply to

    • djay
    • Top 500 Contributor
    • Joined on 06-06-2006
    • Posts 35

    Re: Inserting Optional Section

    ExecuteAction doesn't work very well.  It has a lot of bugs.

    I find it easier to just add the xml directly to the data source.

    Setup a DOM with the data from sampledata.xml to use as your pure source of xml like this: (you will need to modify the namespace line for your form)

    (in C#)

    SampleDOM = (IXMLDOMDocument2)thisXDocument.CreateDOM();

    SampleDOM.async =
    false;SampleDOM.validateOnParse = false;




    Then append the xml your optional section is linked to (I strongly suggest putting your optional section group in a wrapper group with the optional section as the only child):

    IXMLDOMNode parent = thisXDocument.DOM.selectSingleNode("my:root/my:WrapperGroup");

    IXMLDOMNode OptSection = SampleDOM.selectSingleNode("my:root/my:WrapperGroup/my:OptSec").cloneNode(true);



    The section attached to the group my:OptSec should then appear in the view.  This works for repeating tables, etc.

  • 08-20-2008 09:32 PM In reply to

    Re: Inserting Optional Section


    When I insert an optional section and then insert a table within the Optional Section, I somehow end up with an extra blank line under the option section. I can't delete this blank line or changing the formatting does not seem to help.

    Any ideas


  • 08-22-2008 04:28 PM In reply to

    Re: Inserting Optional Section

    Hi, Michael:

    Is this happening when you insert these items using code while the form is being filled out? Or when you are in design mode? If in design mode, check to see the height of your optional section is not set to a fixed number -- set it to auto. Also, you can try making sure you've deleted any blank lines (except the one your cursor is on) prior to inserting a table.

    Hilary Stoupa

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.