Time/Date question - need help!

I have been tasked with creating a view in a DB that shows how many docs have been open since the previous Friday. I can’t for the life of me think of how to do this - any ideas? Thank you SO much in advance

Subject: Question?

Nothing was changed, the document was opened and closed. Correct?

Subject: Another question?

Do you just need the number of documents opened? Or do you to see what documents were opened?

Subject: RE: Another question?

Here’s the scoop…It is a reporting feature that will show how many documents were opened since the previous friday. From there - I need to figure out how many were draft, completed, etc. If I can just get the formula or code for the 1st part, I can do the rest…

The user opens a doc, fills out info, saves and exits. Then a coordinator gets a notification that they need to make a resource assignment. Once the assignment is made, then they close the doc.

Let me know if you need additional info and thanks again in advance!

Subject: Okay!

If the user updates and saves the document, when the document is saved, add a value to the FLAG field, i.e., if TodaysDate is > Friday’s Date, then set flag to 0 else do nothing.

Will this work?

Subject: Possible solution! Two parts.

Part One.

There are times when you do not want a user to be able to close a form by choosing escape or selecting “file/close” from the menu.

In my case I wanted the response document to update totals on the main document before exiting.

This shows one way to force a user to close a form by taking an action you specify. (for example, Clicking an “Update and exit” button.)


My form is in editmode when the user opens it.

If your form is not in edit mode initially, you may want to move the “postopen” code to the “postmodechange” event.

On the form I have a hidden editable field called “EscapeCheck” (Could actually have any name)

In the postopen event of the form as soon as the form opens, I set this editable field “EscapeCheck” to the value “NoExit”:


 Dim session As New NotesSession

 Dim db As NotesDatabase

 Set db = session.CurrentDatabase

 

 Call Source.FieldSetText ("EscapeCheck","NoExit")

The Input Validation event for the EscapeCheck field is coded as…

@If(EscapeCheck=“NoExit”;@Failure(“Please click 'Update and Exit' to Close”);@Success)


In my case, this validation is only done when the document is being saved.

If, in your case, you “refresh” the document some time before exiting you may need to add an @IsDocBeingSaved condition to this formula.

When the user tries to escape from the form, he gets the “Please click ‘Update and Exit’ to close” message and the form does not close.

Note: Update the the final piece to include an update to a flag field.

Final piece is to include the following code in the click event of an “Update and Exit” button.

 Dim workspace As New NotesUIWorkspace

 Dim uidoc As NotesUIDocument

 Set uidoc= workspace.CurrentDocument

 uidoc.editmode = True

 Call uidoc.FieldSetText ("EscapeCheck","OK")

 Call uidoc.Save

This sets the EscapeCheck field to a value other than NoExit and allows the form to close.

(You can add any other updating code your need to this button.)

Part Two.

Create an agent to count the number of documents with the flag value and if you need to see the document, create a view and use the Flag value to display.

Subject: RE: Possible solution! Two parts.

THANK YOU Michael!!!

I will attempt this tomorrow… Any chance you have an agent that does “Part Two” so I could just steal your code?

Subject: RE: Possible solution! Two parts.

Couple of things, if this is simply to find out how many times a document is opened, the above might be beneficial. If, however, you are tracking “open” as in edited, then simply put a time/date field in your document, which stamps the @Now and then do a view selection formula based on the previous Friday’s date and compare against the time/date field you have been setting. Theoretically, it should work, but I have not tried it in a production environment.

Subject: Example Part Two.

This will work if you build a view to hold the Flagged documents.

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim count As Integer

Set db = session.currentdatabase

Set view = db.GetView( “By Author” )

Set doc = view.GetFirstDocument

count = 0

’ begin counting documents

’ stop when there are no more documents

Do Until doc Is Nothing

count = count + 1

Set doc = view.GetNextDocument( doc )

Loop

Messagebox( count )

Or

You could add doc.getfirstitem(“Flag”)and If Flag = “somevalue” then count it, else do nothing. This could run on any view.

Hope this helps!!