Cut down on all those formulae...
Jake Howlett, 5 Febraury 2001
Category: Forms; Keywords: True
False
Role
Admin
Do you ever find yourself writing the same old hide-when formula over and over again. Usually something like:
@Contains("[Admin]"; @UserRoles)
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 value stored in this field is either a 1 or a 0, which Notes interprets as True and False, respectively. This lets you simply place the name of the field in things like Hide-when formulas. The image below is of a paragraph being hidden from people who are not "Administrators":
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...
Copyright © 2000 - 2024 Jake Howlett of Rockall Design ltd. This article was printed from codestore.net