Retrieve the "added in this file" time/date stamp value for a document

This agent will retrieve the value of the "Added In This File" property of a notes document and populate it in string field for easy reference.
LotusScript

(Declarations)

Const wAPIModule = "NNOTES" ' Windows/32
Const NOTE_ADDED_TO_FILE = 13
Declare Private Function ConvertTIMEDATEToText Lib wAPIModule Alias "ConvertTIMEDATEToText" ( Byval zI As Long, Byval zT As Long, T As Long, Byval S As String, Byval nS As Integer, nT As Integer) As Integer
Declare Private Function NSFDbOpen Lib wAPIModule Alias "NSFDbOpen" ( Byval P As String, hDB As Long) As Integer
Declare Private Function NSFDbClose Lib wAPIModule Alias "NSFDbClose" ( Byval hDB As Long) As Integer
Declare Private Function NSFNoteOpen Lib wAPIModule Alias "NSFNoteOpen" ( Byval hDB As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer
Declare Private Function NSFNoteClose Lib wAPIModule Alias "NSFNoteClose" ( Byval hNT As Long) As Integer
Declare Private Function NSFNoteGetInfo Lib wAPIModule Alias "NSFNoteGetInfo" ( Byval hNT As Long, Byval M As Integer, V As Any) As Integer
Declare Private Function OSPathNetConstruct Lib wAPIModule Alias "OSPathNetConstruct" ( Byval zP As Long, Byval S As String, Byval F As String, Byval N As String) As Integer


Sub Initialize
	
	Dim session As New notessession
	Dim db As notesdatabase
	Set db = session.currentdatabase
	Dim collect As notesdocumentcollection
	Set collect = db.unprocesseddocuments
	If collect.count = 0 Then Exit Sub
	Dim doc As notesdocument
	Set doc = collect.getfirstdocument
	
	Dim AddedDateString As String
	
	Do
		AddedDateString = AddedToFile(doc) 
		doc.AddedDateString = AddedDateString
		Call doc.save(True, True)
		
		Set doc = collect.getnextdocument(doc)
	Loop Until doc Is Nothing
	
End Sub


Function AddedToFile(doc As NotesDocument) As String
	
	With doc.ParentDatabase
		db$ = String$(1024, " ")
		OSPathNetConstruct 0, .Server, .FilePath, db$
	End With
	
	Dim hDB As Long
	NSFDbOpen db$, hDB
	If hDB = 0 Then Exit Function
	
	Dim hNT As Long
	Dim T(1) As Long
	NSFNoteOpen hDB, Clng("&H" & doc.NoteID), 0, hNT
	If Not hNT = 0 Then
		NSFNoteGetInfo hNT, NOTE_ADDED_TO_FILE, T(0)
		NSFNoteClose hNT
		s$ = Space(80)
		ConvertTIMEDATEToText 0, 0, T(0), s$, 80, ns%
		AddedToFile = Left$(s$, ns%)
	End If
	
	NSFDbClose hDB
	
End Function 

Images/Screenshots:

Posted by fbrefere001 on Wednesday March 22, 2006