I can’t seem to get this script to work correctly. Any help would be most appreciated.
Here’s what I’m looking for it to accomplish:
Go through the database and when it finds the form ‘Opportunity’ determine if it was created more than 9 months ago (I have it set for three days for testing purposes).
If it was created more than ‘three days ago’ then put the word ‘red’ in the text field called ‘OppAge’.
Go to the next document and repeat.
That’s it. So far it works, but when it comes to putting the text into the field it either isn’t saving correctly or I’m just not putting the value in correctly.
Thank you for any help that is offered.
Sub Initialize
Dim s As New NotesSession
Dim doc As NotesDocument
Dim dc As NotesDocumentCollection
Dim db As NotesDatabase
Dim i As Integer
Dim CreatedDate As NotesDateTime
Dim CurrentDate As NotesDateTime
Dim ModifiedDate As NotesDateTime
Dim Item As String
Set db = s.currentdatabase
Set dc = db.alldocuments
Set doc = dc.GetFirstDocument
Set CurrentDate = New NotesDateTime(Today)
Call CurrentDate.AdjustDay( -3 )
For i = 1 To dc.count
Set CreatedDate = New NotesDateTime(doc.Created)
If CurrentDate.TimeDifference( CreatedDate ) > 0 Then
doc.OppAge = "red"
Call doc.Save(True, True)
End If
Next
For i = 1 To dc.count Set CreatedDate = New NotesDateTime(doc.Created)
If CurrentDate.TimeDifference( CreatedDate ) > 0 Then
doc.OppAge = "red"
Call doc.Save(True, True)
End If
Set doc = dc.GetNextDocument(doc)
Next
Dim s As New NotesSession
Dim doc As NotesDocument
Dim tempdoc As notesdocument
Dim dc As NotesDocumentCollection
Dim db As NotesDatabase
Dim i As Integer
Dim CreatedDate As NotesDateTime
Dim CurrentDate As NotesDateTime
Dim ModifiedDate As NotesDateTime
Dim Item As String
Set db = s.currentdatabase
Set dc = db.alldocuments
Set doc = dc.GetFirstDocument
Set CurrentDate = New NotesDateTime(Today)
Call CurrentDate.AdjustDay( -3 )
While Not doc Is Nothing
Set tempdoc=doc
Set CreatedDate = New NotesDateTime(tempdoc.Created)
’ If CurrentDate.TimeDifference( CreatedDate ) > 0 Then
If CurrentDate.TimeDifference( CreatedDate ) > 0 And tempdoc.form(0)="Opportunity" Then
tempdoc.OppAge = "red"
End If
Set doc = dc.getNextDocument(doc)
Call tempdoc.Save(True, True)
Wend