@GetCurrentTimeZone in View Column

I am trying to display the difference in hours (i.e. +1.5, -2.0) between a time zone recorded in a field on a document and the current time zone for the user’s computer in a view column. According to the help, the @GetCurrentTimeZone is supported for column formula. I’ve got the formula to calculate the difference and it works, but it seems to be dependent on the view index. For example when I first add the column to the view, it displays correctly the hours between my current time zone (EST) and that of the time zone on the document. If I then change my time zone in my OS, the column doesn’t update (even after re-starting both the Notes client and computer). If I add a column that uses something like @Now, every time I open the view the index is refreshed and I then get the correct difference in hours, but am now faced with a view that has performance issues, albeit perhaps what I’m asking it to do in theory would require that performance issue regardless as I’m trying to get it to do this for each user. This is an application that is used by users in several time zones, and I’m asked to provide them with an easy way to know how far ahead/back the time is for the document with the time zone recorded. I have done several searches on the internet on this issue, but haven’t come across anyone indicating that it’s a problem, or something they have done.I haven’t included any code, as it seems to work as I want it, just not updated as I’d expect, but can include the code if you feel it may be helpful.

I hope this all makes sense. Thanks in advance.

Regards, Henry

Subject: Re: @GetCurrentTimeZone in View Column

Any function used in a view column of a shared view, will not display information about the end user or the end user’s workstation. The only reason it appears to be working somewhat, is that you’re doing it in a local copy of the database.

The reason it works this way, is that the server calculates the view index – which includes the values for all columns – once for all users to share, not individually for each user. So you would be getting the time zone of the server, not the workstation.

A local replica, or a “desktop private” view, will use the user’s and workstation’s information because it’s calculated on the workstation instead of on the server.

However, the view indexer also assumes that it can calculate the values in the view columns of a particular document once, and not have to recalculate them unless the document is modified. There’s an exception if the view uses @Now and @Today, because obviously the values of these functions will change without the documents having changed. There are other functions that could change values, but the indexer doesn’t assume they will. @GetCurrentTimeZone is one of those.

So even if you use a “desktop private on first use” view, it will not automatically notice a user’s change of time zone on their workstation and know to recalculate the view index for documents that were already listed there from before. However, you could add that logic yourself in the view PostOpen event; check the value of @GetCurrentTimeZone, compare it to a value you have stored in an environment variable, and if it’s different, use uiws.ViewRebuild.

This solution may have problems if the view sometimes opens in a setting where it does not initially have focus (e.g. in a frameset where some other frame has focus initially). The ViewRebuild would fail, or rebuild the wrong view. Checking to make sure uiws.CurrentView is the same view before you do this, is a good idea. In that case, SetTargetFrame might work (probably not) or you could just tell the user to do it themselves.

Unfortunately, NotesUIView doesn’t have a Rebuild method, and for a desktop private view the View property doesn’t return a useful value.

Subject: Update Help Documentation??

Andre

Thanks for the response. It all makes sense. I saw the help documentation indicate it would work in a column formula, with no caveats. I wonder if the help for the formula should be updated to have an asterisk (*) in the ‘Where does this @function work’ for the view column context.

Regards,

Henry

Subject: On updating help documents

It’s an interesting idea. Every help document contains a feedback link at the bottom. Please use this link to submit your suggestion. We have staff assigned to read these and act on them.