I am requesting help with a formula.
I have a column in a view named “Processed Date”. I am trying to bring back the date of when a document has been processed by an agent and notrix job. I was using the last modified date which would work fine with the exception that a select group of users are allowed to go in and edit the document after it has been processed so this doesn’t work.
Is there a way to do this?
Below is the code for the agent:
Option Public
Option Declare
Use “OpenLogFunctions”
Dim s As NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim profDoc As NotesDocument
Dim o As NotesEmbeddedObject
Dim dtEAS As NotesDateTime
Dim filePath As String
Dim filePathIndex As String
Dim result As Variant
Dim docCount As Long
Dim aCount As Long
Dim fileName As String
Dim docID As String
Dim errMsg As String
Dim fileNum As Integer
Dim fileNameIndex As String
Dim sep As String
Dim msgLog As String
Dim newLine As String
Sub Initialize
'extract attachments from payment reqs that are are ready to go to EAS. Gets extraction file path from AppProfile.
'NOTE: This should run after the 'Process Reqs On Hold' agent daily
On Error Goto Err_Init
newLine = Chr$(13)
msgLog = ""
Set s = New NotesSession
Set db = s.CurrentDatabase
Set profDoc = db.GetProfileDocument("AppProfile")
filePath = profDoc.ap_CMExtractLocation(0) 'location to save attachment files to
filePathIndex = profDoc.ap_CMExtractIndexLocation(0) 'location to save index files to
If filePath = "" Or filePathIndex = "" Then
msgLog = msgLog & "Both index and attachment file paths are not assigned in AppProfile, cannot perform extraction." & newLine
Call LogErrorEx(msgLog, SEVERITY_HIGH, Nothing)
Goto Exit_Init
Else
msgLog = msgLog & "Extracting Attachments to: " & filePath & newLine
msgLog = msgLog & "Create AttachmentIndex.txt file at:" & filePathIndex & newLine
'create index text file to have 1 row per document
fileNum% = Freefile()
fileNameIndex = filePathIndex & "\AttachmentIndex.flat"
Open fileNameIndex For Output As fileNum%
sep = "#"
docCount = 0
aCount = 0
'get all docs with StatusNum = 8 (Ready for EAS)
Set col = db.Search({StatusNum = 8}, Nothing, 0)
Set doc = col.GetFirstDocument
While Not( doc Is Nothing )
'extract attachments from each document
docID = doc.ReferenceID(0)
'msgLog = msgLog & "Processing doc " & Cstr(docCount) & ": " & docID & newLine
If doc.HasEmbedded Then
result = Evaluate({@AttachmentNames}, doc) 'get attachment names
Forall i In result
If i <> "" Then
’ Set o = doc.GetAttachment( result(0) )
Set o = doc.GetAttachment( i )
fileName = filePath & "\" & docID & "_" & o.Source 'extracts attachment as [ filePath\docID_OriginalFileName ]
Call o.ExtractFile( fileName )
WriteIndexFileRow
aCount = aCount + 1
End If
End Forall
docCount = docCount + 1
End If
doc.CMAttachmentsExtracted = Now
doc.lstStatus = "Attachments Extracted"
doc.StatusNum = 9
Call doc.Save(True, False)
docCount = docCount + 1
Set doc = col.GetNextDocument( doc )
Wend
Close fileNum%
End If
msgLog = msgLog & "Agent Complete - Detached " & aCount & " files from " & docCount & " docs"
Exit_Init:
Exit Sub
Err_Init:
On Error Goto 0
errMsg = Error$ & "; Line: " & Erl 'for use when debugger is on
Call LogErrorEx("Error: " & Error$ & newLine & newLine & "Log:" & newLine & msgLog, SEVERITY_HIGH, Nothing)
Resume Exit_Init
End Sub
Sub WriteIndexFileRow()
'Data is: AccountsPayable, VendorId, VendorName, MMCCYY, CreateDate, PrimeSub, CostCenter, BatchVoucher, DocumentType
Dim col1 As String, col2 As String, col3 As String, col4 As String, col5 As String, col6 As String, col7 As String, col8 As String, col9 As String, col10 As String
col1 = "AccountsPayable" 'AccountsPayable
col2 = Ucase(doc.PayeeCode(0)) 'VendorID
col3 = Ucase(doc.NamePayee(0)) 'VendorName
col4 = doc.DateEAS_Mo(0) & doc.DateEAS_Yr4(0) 'MMCCYY
col5 = doc.DateEAS_Mo(0) & "/" & doc.DateEAS_Dy(0) & "/" & doc.DateEAS_Yr4(0) 'CreateDate
col6 = Ucase(doc.AcctNo_1(0)) 'PrimeSub
col7 = Ucase(doc.CostCenter_1(0)) 'CostCenter
col8 = Trim(Ucase(doc.ReferenceID(0))) 'BatchVoucher
col9 = "ACCREQ" 'DocumentType
col10 = fileName
Print #fileNum%, col1 & sep & col2 & sep & col3 & sep & col4 & sep & col5 & sep & col6 & sep & col7 & sep & col8 & sep & col9 & sep & col10
End Sub