Freigeben über


Dynamically Hide/Disable controls in InfoPath 2003

Working on InfoPath form is an easy affair as long as, developers use it for the sole purpose of its creation (Creating a simple forms to capture data and publish them to a server for sharing). The moment this rule is broken, the increase in the complexity will be directly proportional to the features being implemented.

There are situations where you may need to perform some action based on the currently logged in User, the role of the user or some other parameter.

Recently, I was working on something which required us to do some UI validations based on the user logged in. We cannot directly use the user roles provided as the user names will be stored in a database and we need to set the UI according to the user preferences.

This is not a straight forward task in InfoPath (though, I dont want to call it tedious aswell) as InfoPath does not work that way.

So, we had to work on several work arounds and found a very simple alternative.

In the attached sample, you can type in the any username in the user name textbox and the dropdown will be disabled as soon as the username is identified as the current windows username.

Pretty simple code... just look at how simple InfoPath makes things.

DynamicallyHide.zip

Comments

  • Anonymous
    August 31, 2007
    Thank you for your efforts at making this available online. I've been searching for a work around this issue.