Is my Lotus Notes database being used on the web or the Lotus Notes client?
June 7th, 2007
Have you ever wanted to determine whether you code or design element was running on the web or in the Lotus Notes client?
One way of achieving this was to test for the server name. If we new that our ISP's Domino server was names WebServer/MyISP then we could easily check this name, for example using @DbName, and then take the appropriate action. Of course this didn't work if our application on the server was accessed by both Notes clients and web browsers. An of course hard-coding the Domino server name is considered very bad practice because if the Lotus Notes application was ever moved to another Domino server someone would have to go through the application and change all the hard-coded references to the old Domino server.
Thankfully Lotus added a new feature as an easy way to determine if the current context is the web browser of the Lotus Notes client. Lotus added a new role called $$WebClient. This role is automatically added to the application user's list of roles if the current context is a web browser. This make it very easy to determine if the current context is a web browser or the Lotus Notes client.
@UserRoles has been a part of the Lotus Notes Formula language for a long time. It returns a list of the roles assigned to the current user.
So, for example, if we want to hide something on the web, all we need to do is use the following hide-when formula:
@Contains(@UserRoles; "$$WebClient")
and if course if we want to hid something from the Lotus Notes client then we only have to "not" the formula:
@Contains(@UserRoles; "$$WebClient")
This formula is great because it works in so many places, documents, forms, view columns and more.
Good hidings to you!