Do you ever find yourself writing the same old hide-when formula over and over again. Usually something like:
Not only do these type of mini-formulae seem to get everywhere, they usually popup more than once on the same form. To that end, it is obviously beneficial to have it computed once and then be able to reference the result from the rest of the form...
Probably the best way to do this is to use Computed-for-display fields (we don't need to save this information) that can then be easily referred to throughout the form.
Let's take the example used above where we check whether the user is an "Administrator" or not. Follow these steps to create the field:
- Create a Computed For Display field
- Call it isAdmin
- Hide it from Notes and the Web
- Place this formula in to its Value @Contains("[Admin]"; @UserRoles)
The uses are almost endless. Consider this formula that could be used in a Computed-text area to create a link that opens a view depending on the field value:
"<a href=\"" + DBPath + "/Docs"+ @If(isAdmin; "Admin"; "Normal") + "?OpenView\">Documents</a>".
Not only does this save the server from doing a little more work than in necessary it also saves you having to remember the syntax to the @Formulae. I don't know about you but I always seem to forget the correct order of arguments and syntax to these simple functions.
You can do similar things with fields like isIE, isNN, isVersion4, isWeekday, isAnybodyStillReadingThis and so on. Well, OK, maybe not that last one, but you get the idea. The final step is to place all these fields in to a subform that you then can place in all the other forms that will no doubt benefit...