How do I disable a section in Infopath?

R

Ryan Spencer

I have a need to lock a section from being modified, but do not want to hide
it. The information is important to be visible, but cannot be modified. I
understand the digital signature portion will do this, however we are not in
a position to enable this, and it does not fit with our business process.
 
F

Franck Dauché

Hi,

Can't you make each element in your section (textboxes, checkboxes, etc.)
read-only? It would do the trick.
Now, if it is a repeating section, you can also disable the ability to add
or remove feature to make sure everything is read-only.

Franck
 
R

Ryan Spencer

Thanks for the reply Franck...

Yes, I can make every element read-only (with the exception of option
buttons and check boxes). They must be "disabled" as they do not have a
read-only property.

The problem I have (which many people in the forums are having) is that I
need to lock a form down after an approval or submission so that the data
cannot be modified. I have set a conditional view to disable each and every
control in a section based upon a value (my approval check box) but this was
EXTREMELY time consuming and gave me carpal tunnel syndrome. With over 100
controls, writing the rule for every single one was not very effective.

I thought I could use views to accomplish it, but it turns out I cannot lock
the fields in a view - I have the same problem. AND Infopath does not allow
you to make an option button or check box read only, so even in the views I
had to write the same rules for all these controls.

What really bothers me is that a section can be disabled ONLY if you use
their digital signature function. So the technology is there to do it, they
just don't give you the option in a conditional format - they only provide a
hide function.

It is killing me. They get 90% there and then fall on their face with the
simple things.

Thanks.
 
F

Franck Dauché

Hi Ryan,

You are right. The only way if to point to a node in your schema to decide
if each control should be read-only or not or to use a custom function in
managed code to build complex logic. In both cases, you have to go control
by control......sorry for your wrist.

Franck
 
G

G. Tarazi

Hi



We had the same problem before, there is no need to block it control by
control, and there is a simpler way.



Create an "before change" event handler on the base data element, for
example, if the base schema element is called MyForm (in the main data
source), create an "before change" event handler on it.



Add the code logic to verify if the form must be read only, and when
applicable, use this code:

(This is a C# sample)



[InfoPathEventHandler(MatchPath="/my:myFields",
EventType=InfoPathEventType.OnBeforeChange)]

public void myFields_OnBeforeChange(DataDOMEvent e)

{

// Your logic here

bool readOnly = true;



if(readOnly)

{

e.ReturnStatus = false;

e.ReturnMessage = "This form is read only!";

}

}



Not perfect I know, but it does the job.



In an ideal world, you will tell the form its read only, and all the
controls will convert themselves on the screen to labels.
 

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