![]() | ![]() |
|
08-17-2010 04:09 PM
There has always been a need in our company to occasionally change field behavior on the fly, based on other selections made on the same form. For example, if the user says a deal on the pipeline is going to be serviced in house the provided Loan Number field on the same field would become required. If it is going to be serviced externally, the Loan Number field would just be optional.
In previous versions, the recommended way to accomplish such a feat was to use the good old "create two versions of the same field" method with a checkbox in the background turning visibility of the required/optional fields on and off.
Now that we are experimenting with a side-by-side v7.6.3 and v9.0.1 interface, on our development environment, this same situation has prompted some curiosity on if the best practice for accomplishing flexible field behavior has changed with some of the more recent enhancements.
Namely, is there a way in v9 to use a Code Activity on the "When Field Changed" property to switch between Read Only, Required, Optional and Hidden?
08-17-2010 08:25 PM
As far as I am aware there are no methods to change usage, certainly no supported ones. I suspect there would be a hack invented at some point, although our experience is that these are more effort than they are worth in the long run.
The 'two fields' solution, as you are probably aware, is problematic because of the risk of overwritting the variable with one field, not the eneretd field, hence you need another variable. In v9, the same approach is probably a good one, and the ability to have 'local' variables not tied to database fields makes the solution somewhat neater.
08-18-2010 04:40 AM
Use javascript. Make the field optional for all, but have a client-side javascript function on the form submission which returns true or false. Then in the javascript put a check in for the two fields to see if they match up as you want. If they're not right, alert the user to the error, return false and the form won't submit. I do this all the time. It's the safest and most maintainable thing you can do.
BUT, be aware that the best way to access fields in javascript has changed between v7.6 and v9, in v9 you're best using the GetField() function, but in previous versions it was often better to use document.all[fieldname].value to avoid looping though tons of metastorm code.
Hope this helps.
![]() |
![]() |
![]() |
|
|
![]() |
![]() |
![]() |
















