329 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Jobs | Twitter | Bookmarks | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Beware <script> in XPages
Wed, May 15th 2013 345
Working the system to get bugs fixed
Mon, May 13th 2013 157
Delete empty folders, take 2
Wed, Apr 10th 2013 238
@IsNotesBrowserPlugin
Wed, Mar 20th 2013 308
Are Apple customers allowed to marry non-Apple users?
Mon, Jan 21st 2013 524
Searching for design elements 100 times faster
Tue, Jan 8th 2013 536
Speak at Pulse?
Wed, Oct 17th 2012 344
Top 10
Searching for design elements 100 times faster
Tue, Jan 8th 2013 536
Are Apple customers allowed to marry non-Apple users?
Mon, Jan 21st 2013 524
Better SSJS validation for XPages
Wed, Jan 5th 2011 381
Beware <script> in XPages
Wed, May 15th 2013 345
Speak at Pulse?
Wed, Oct 17th 2012 344
Sample code for LCLSX file attachments article
Wed, Sep 5th 2012 339
New Best Practices Wiki
Tue, Jan 10th 2012 313
@IsNotesBrowserPlugin
Wed, Mar 20th 2013 308
Why inboxes fail
Wed, Jun 13th 2012 298
Another way to make an efficient date/based view
Mon, May 23rd 2011 276


Another way to make an efficient date/based view
Andre Guirard    

This technique isn't applicable in all situations, but it's a way to make a date or time-based view whose index is only rebuilt when needed, and doesn't require that the date be hardcoded into a design element. The example is intended for use in the Notes mail file, where there's only one user who we're mainly concerned about. It could be used in a shared app context, but in that case it should be set up to use the server's time settings, not the client's as in this example, since different users would be plugging in different formulas and causing constant rebuilds based on their client's settings as opposed to someone else's.
The problem is how to get the view index to be rebuilt only when it is needed, and without "flashing" (i.e. we don't want to open the view and then notice it's out of date). I've been testing this solution and it seems to work.


In the folder, you define a UDC (user-definable column) whose item name is, say "$ZoneDay":

Image:Another way to make an efficient date/based viewImage:Another way to make an efficient date/based view
We use the profile name ColorProfile because the Inbox already contains another UDC with the same profile, and any given view can only use one profile doc for UDCs.


Now, you have to set up the profile document to contain the correct formula for the date-based value you'd like it to display. For this we can use the view's queryopen event, for instance:

Sub Queryopen(Source As Notesuiview, Continue As Variant)
       Dim db As NotesDatabase, sess As New notessession

       Set db = sess.CurrentDatabase

       Dim docPro As NotesDocument, curFormula$, newFormula$, midnight$, gmtMid

       Dim tmpTime As New NotesDateTime("")

       tmpTime.lslocaltime = Today ' which translates to today at midnight.

       gmtMid = tmpTime.LSGMTTime

       midnight = {@ToTime(@Text(@Date(} & Year(gmtMid) & {; } & Month(gmtMid) & {; } & Day(gmtMid) & {; } & Hour(gmtMid) & {; } & Minute(gmtMid) & {; 0)) + " GMT")}

       
       Set docPro = db.GetProfileDocument("colorprofile")

       curFormula = Replace(docPro.GetItemValue("$ZoneDay")(0), Chr$(13), "")

       newFormula = {todayMid := } & midnight & {;

daysOld := (todayMid-PostedDate) / 86400;

@If(daysOld <= 0; "today"; daysOld <= 1; "yesterday"; "older " + @Text(@Integer(daysOld)))}

       If curFormula <> newFormula Then

               docPro.ReplaceItemValue "$ZoneDay", newFormula

               docPro.Save True, False, True

       End If

End Sub


Some comments about this approach:
  • On the line beginning "midnight =", we represent the date by using the @Date function with six arguments. This is done rather than just hardcoding the time constant [mm/dd/yyyy hh:mm:ss GMT] for instance, because we have no way to know the server's date formatting settings. The formula has to be comprehensible by the server, but this code executes on the client, so we can't just format the date as the client would by default.
  • If performance ends up being a problem and you want to find a way to format the date so the server understands it, you might:
    • try using the @TimeMerge function.
    • see whether the format [yyyy/mm/dd hh:mm:ss am/pm] is interpreted the same by all servers (note, however, that "/" might not be universally used as a date delimiter).
    • I'm trying to get a way of representing date/times that's static across all platforms and settings, e.g. as a hex code. I need it for DXL, but as we can see here there are other applications for it.
  • When it's asked to open the view, the view indexer is smart enough to know that if the profile document (colorprofile in this case) has been modified since the view was last opened, that means that a column formula might evaluate differently for existing documents. So it knows in that case to rebuild the view index rather than refreshing. So don't save changes to the profile doc unless you mean it.
  • This approach is doesn't require Designer access for the end user, only enough authority to edit a shared profile document, which they need anyway to edit their own mail preferences. In other applications where users might not have enough muscle to do this, you might need to make the profile document contain an explicit Authors field to allow this access. It could get tricky, which is why I say this might not be applicable for all apps.
  • If you wanted to use the server's timezone settings to determine the day divisions, instead of the client's settings, you can get rid of the timezone stuff and just use the @Date function (you still can't hardcode the date in [brackets] without knowing how the server formats dates).
  • There's an extra argument to @Now to return the server's current time, and you can use that to determine what the server thinks the date is. This is not 100% obvious how to do; I think you'll have to use @Text in your Evaluate call with certain arguments, to get the time in the server's zone.


---------------------
http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/another-way-to-make-an-efficient-datebased-view
May 23, 2011
277 hits



Recent Blog Posts
345


Beware <script> in XPages
Wed, May 15th 2013 12:30p   Andre Guirard
I may be stating the obvious, but I wasn't the only one on my team caught out by this, so I thought I'd best mention it. I recently discovered the hard way that there's a problem with using elements in XPages. Always use instead. Why, you ask? Either seems to work fine! The problem comes up if your application is translated. The code that decides what parts of your page are translatable doesn't know anything about the element, so your JavaScript code is marked as a localizable string. It [read] Keywords: ldd lotus xpages application best practice javascript
157


Working the system to get bugs fixed
Mon, May 13th 2013 9:20a   Andre Guirard
An issue recently came to my attention that (based on my informal poll) has been a thorn in the side for Domino administrators for quite a while. I've been trying to figure out how it is that it's never been fixed. I'm referring to the fact that end users, when they create or rename a folder, are allowed to use various characters that have special meanings in design element names -- backslash, vertical bar, underscore, forward slash (which causes problems in mobile) and enclosing the name in [read] Keywords: domino ibm ldd lotus notes notes client notesdomino bug development ideajam mobile
238


Delete empty folders, take 2
Wed, Apr 10th 2013 9:50a   Andre Guirard
I while back I wrote a post containing code to clean up empty folders from user mail files. Yesterday, someone pointed out to me that it doesn't take into account the fact that folders that contain subfolders can be technically empty, in the sense of containing no documents, but we don't want to delete them if they have subfolders which are non-empty -- or if they have subfolders we don't also want to delete. So I came up with a new version of the code that deals with those situations. As bac [read] Keywords: ldd lotus lotusscript application
308


@IsNotesBrowserPlugin
Wed, Mar 20th 2013 7:40a   Andre Guirard
In case it makes a difference for your application, here's how to tell whether you're running in the Notes browser plugin. So far, the only difference that's mattered to me is that the [FileExit] command doesn't work in NBP, causing an error dialog if you try it. %REM Function IsNotesBrowserPlugin Description: Return TRUE if we're running in the Notes browser plugin. %END REM Function IsNotesBrowserPlugin As Boolean Dim session As New NotesSession [read] Keywords: ldd lotus notes application
524


Are Apple customers allowed to marry non-Apple users?
Mon, Jan 21st 2013 2:00p   Andre Guirard
It's been an ordeal. I have an Android smartphone and use Gmail's calendar. My wife has an iPhone. You'd think it would be simple to have a shared calendar -- this is, after all, the future. As it turns out, it is possible, but the arduous process has made me wonder whether Apple considers it a form of apostasy for their customers to associate with someone who doesn't use their products. We had two alternatives to start with: we could create our shared calendar in Gmail or iCloud. No prefere [read] Keywords: ibm ldd lotus notes apple email google interface iphone java
536


Searching for design elements 100 times faster
Tue, Jan 8th 2013 9:40a   Andre Guirard
Often, entries in this blog are in reaction to questions I get, or someone else's code I've run across. One of the reasons things have been so quiet here is that my job has changed so that's not happening as often. But every now and them I'm reminded that there are things I know that it hadn't occurred to me weren't obvious, until I run across another developer who didn't know it. That's the case with this tip. Someone mentioned that it was taking their code a long time to scan mail file [read] Keywords: ldd lotus lotusscript database java network server




344


Speak at Pulse?
Wed, Oct 17th 2012 12:20p   Andre Guirard
If you're thinking of submitting an abstract to the Pulse 2013 conference in Las Vegas, you might like to register for this webcast that explains the process. If you've been doing something interesting with IBM technologies, here's your chance to shine! [read] Keywords: ibm ldd lotus tivoli
339


Sample code for LCLSX file attachments article
Wed, Sep 5th 2012 1:50p   Andre Guirard
I keep getting asked where to get the sample code for the article "Working with file attachments in the LCLSX", which used to be in the Lotus Sandbox before that went away. The code is here: LcLsxTracy.nsf [read] Keywords: ibm ldd lotus lotusscript
298


Why inboxes fail
Wed, Jun 13th 2012 6:53p   Andre Guirard
I've been doing some research recently into what causes email to fail to be delivered into inboxes, although it is visible in the All Documents view. I was concerned with this mainly because the recommended corrective action (copy compact) isn't an option for SmartCloud Notes users and their local admins, who don't have access to the users' mail servers to issue console commands. Conventional wisdom, and our technotes, claim that the problem is that the "inbox index gets corrupted". But it [read] Keywords: admin ldd lotus notes notes client bug database email
183


You can read a story of mine...
Thu, May 10th 2012 6:10a   Andre Guirard
In the recent anthology Sky-Tinted Waters from SamsDot, my story "Misprint" appears. It's about a young stage magician and a trick that works a little too well, and the dangers of not reading ahead to the end of the instructions. The other stories are also very good and I'm enjoying reading it. I hope a bunch of you will buy copies, and that you'll find the stories entertaining. No ebook version is planned at present. [read] Keywords: ldd lotus




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition