IP2007 - Setting field properties from code

B

Bruce Sandeman

Hi,
I have a form in which I need to hide certain fields and show certains
fields as well as set some to read/only and others to read/write depending on
Active Directory group membership of the current user.
I cannot use views as I already have 16 views in the form to control field
sets that are displayed dependent on source data. If I create more views to
be switched from code, I will end up with about 144 different views, which is
not what I want due to form maintenance then becoming nigh on impossible.
As such I need to use either VSTA or VSTO to do this. I cannot work out how
to change the properties of a field such that it becomes hidden or read/only
etc....
Can anyone help me out?
thanks very much
cheers
Bruce
 
B

Ben Walters

Hey Bruce,
You can rest assured that VSTA or VSTO won't be nessasary, if you have a
look in the tools menu you should see a User Roles option, From here you can
setup user roles based on your AD groups.

Once those rolse have been setup you can then use the condition formatting
option for each of your fields and set them to hidden, read only etc...
based on the role the user is currently logged in as.


if you still need more info let me know and I'll put up a post on how to do
this

Cheers
Ben
 
B

Bruce Sandeman

Thanks Ben,
Perhaps I should've mentioned that I am restricted to using Infopath Forms
Services within MOSS 2007 and therefore User Roles are not supported.
I have got a little bit further with this in so far as I have now populated
a field with the value of the AD group such that diff fields can be adjusted
depending on that field's value, which seems to work for read/only and hidden
fields, however it doesn't seem to work for making fields required or
optional as I can't seem to find anyway of doing this.
any ideas?
thanks very much
cheers
Bruce
 
B

Ben Walters

Hey Bruce,
Sorry to say there is no way to set a field to optional or required at run
time.
The only way I could think to do this is to setup some rules using the data
validation on your field.

e.g.
When Field1 = Admin
and Field2 is blank
Add screen tip to the form


Hope this helps

Cheers
Ben
 
B

Bruce Sandeman

Thanks Ben,
That's what I thought, I've set my code to populate a field with a value and
then made other fields use that field value within the validation section to
put up a validation message.
thanks very much
cheers
Bruce
 

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