@SetField in Queryclose not working

I am having a problem trying to set a field on my form in the Queryclose of the form’s Globals.

I am able to get the @SetField in the Queryopen to capture User Name and Time of when the doc was opened ( Not opened for edited, just opened for preview), but this does not work on the way out in the Queryclose.

What I am trying to accomplish is track how long a user is in a document (Again, not opened for edited, just opened for preview). I want to see only up to the past 25 user.

----------------- Sample Queryopen Code - TIME IN ( This works fine) -------------------

@SetField(“LhN”;

@If(LhN = "";0;

      @If(@Elements (LhN) > 24; @Subset (LhN; -24); LhN) : (@Subset (LhN; -1) + 1)));

UserName := @Name([Abbreviate]; @UserName);

@SetField(“LhReader”;

 @If(LhReader = "";

      UserName;

      @If(@Elements (LhReader) > 24; @Subset (LhReader; -24); LhReader) : UserName));

@SetField(“LhDate”;

 @If(LhDate = "";

      @Now;

      @If(@Elements (LhDate) > 24; @Subset (LhDate; -24); LhDate) : @Now))

------------------------------ End of Code ---------------------------------

-------- Sample Queryclose Code - TIME OUT (This does not works) ------------------

@SetField(“ULhDate”;

 @If(ULhDate = "";

      @Now;

      @If(@Elements (ULhDate) > 24; @Subset (ULhDate; -24); ULhDate) : @Now))

------------------------------ End of Code ---------------------------------

Has anyone done anything like this before? If so how was it done? It appears to me that the @Setfield in the Queryclose is not the answers, maybe I’m wrong.

Thank in advance

BB

NWF

Subject: @SetField in Queryclose not working

Changes in field values made while a form is open in read mode, will not be saved. You would have to use LotusScript to make changes to the fields in the back-end (NotesDocument) and then use NotesDocument.Save to save it.

By the way, modifying a document every time a user reads it is, by and large, a really bad idea. This causes a tremendous number of modified documents that have to be reindexed into all the views, replicated to any other replicas, etcetera, all of which hurt performance. Even worse, if two users are reading the document at the same time, they’re both trying to save changes to their version, resulting in a save conflict.

Subject: @SetField in Queryclose not working

You can’t set field values in the front end document in queryclose or postsave. Those events fire AFTER the doc is saved, so no changes made in them would be saved. You could use querysave, but then you’d have to handle multiple entries per edit when the user saves more than once per edit session.

If you set a global variable with the time (using LotusScript) in postopen, and then in queryclose, you open the back end document and update it with the calculated duration, it should work fine for docs opened into read mode. For edited docs, however, I’m not sure if you’d get a save conflict or not by opening after save but before close. Maybe someone else will post as to that point. File Save probably knows.

I think I’ve also seen postings in the forums from people who have created such an activity log using another database, but regardless, have you investigated whether R6’s activity logging will give you the detail you need? I’m on an R5 machine myself right now, and I don’t remember the details, but I recall there’s a fair amount of stuff that gets recorded per user per database in terms of bytes and minutes.

Subject: RE: @SetField in Queryclose not working

Thanks for all you input.I will research the activity log and scrap the Queryclose method.