Optional Sections with "Cannot be Blank" Elements

D

David (Perth,WA)

I'm trying to have an optional section which displays when a checkbox is
checked (true). Within the optional section are a number of "cannot be
blank" elements, so I can't just use the Conditional Formatting functionality.

I've tried the process described at:
http://blogs.msdn.com/infopath/archive/2004/08/03/207151.aspx

However, even using the basic form described therein I receive a message:
"The attempted fragment operation cannot be completed because there is no
valid insertion point for the fragment." everytime I check the checkbox.
This is followed by the error: "The specified pxnStartNode value for the
View.SelectNodes call is not valid." when I clear the checkbox.

Can anyone help me resolve these problems?

Thanks.
 
D

David (Perth,WA)

Further to this issue:
I've run the script debugger and it seems to run the OnAfterChange script
twice - first time through is fine, second time through causes the error.

Why on earth would the OnAfterChange event handler be called twice?
 
V

vt_asparagus

I have had issues too working with XDocument.View.ExecuteAction(...).
Have you tried using a section rather than an optional group? Since
your fields are required it may not make sense to have them within an
optional group.

Try this (save a copy of your file to the side so you do not loose
anything):
1 - Remove the optional section.
2 - Drag and drop a section control onto your form.
3 - Place any required fields within that section.
4 - Double click on the section to get to the properties window for it.
Go to conitional formatting on the Display tab and press Add. There
is a "hide this control textbox" which you can use. Just add
conditional logic to verify if the checkbox is checked.
 
D

David (Perth,WA)

Thanks for the advice.

I did as you suggested but hit a problem: the controls in the hidden section
are mandatory if the checkbox is checked. If I do as you suggest then they
are still part of the schema even if the checkbox is cleared and will fail
validation when I save.
 
D

David (Perth,WA)

Delving deep into the SDK documentation reveals that the OnAfterChange "event
handler" may indeed be called twice - once for "insert" and once for "delete"
operations - even though there is only one "event".

May be it's just me, but this is insane - I have to place a conditional
statement within an event handler to prevent it running twice in response to
a single user-triggered event.

I could *almost* understand if the event was triggered by the value I'm
changing in the XML Schema (i.e. the insert/delete of the hidden controls)
but this is being triggered on a separate control (the checkbox).

Since when did it become reasonable to expect an event handler to be
triggered twice by a single event? :-/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top