Dear all expert,
Can you kindly help me to look into this code where I have an error Object Variable Not Set, my script is as below:
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Dim db As NotesDatabase
Dim view As NotesView
Set db = session.currentdatabase
Set doc = New notesdocument(db)
Set doc = session.DocumentContext
Set db = session.CurrentDatabase
Dim newDoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim thisdoc As NotesDocument
Dim item As notesitem
Dim dateTime As New NotesDateTime( “” ) dateTime.LSLocalTime = Now
varA = doc.zTempDate(0)
varB = doc.zTempDescription(0)
varC = doc.Reason(0)
varD = doc.zTempRoute(0)
'Reminder
Dim weekDateTime As NotesDateTime
Dim modifiedDateTime As NotesDateTime
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Set weekDateTime = New NotesDateTime( “Today” )
Set modifiedDateTime = New NotesDateTime( “” )
Call weekDateTime.AdjustDay( -2 ) ’ set to one week ago
modifiedDateTime.LSLocalTime = doc.LastModified
If weekDateTime.TimeDifferenceDouble( modifiedDateTime ) > 0 Then
Set newDoc = New NotesDocument( db )
newDoc.Form = “Memo”
newDoc.Subject = “Reminder: please update your Decision”
Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))
Call newDoc.Send( False, doc.zTempRoute )
End If
If doc.Approval(0)=“Approve” Then
zTempSign = “Department Head:” + Chr(9) + Chr(9) + varD + " (" + dateTime.DateOnly + ", " + dateTime.TimeOnly + “) - Approved” + Chr(10) + Chr(10)
Set item = doc.GetFirstItem(“zSign”)
Call item.AppendToTextList(zTempSign)
Set newDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newDoc, “Body” )
Call rtitem.appendtext(“Please be informed that the following form is seeking for your approval.” + Chr(10) + Chr(10) + “Please click on the icon below for your perusal.”+Chr(10)+Chr(10))
Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))
newDoc.Subject = “E - Signboard Application : Marketing Verification” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)
newDoc.SendTo = doc.GetItemValue(“zSBMktg”)
newDoc.Send( False )
Set newDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newDoc, “Body” )
Call rtitem.appendtext(“Please be informed that the following form has been approved by Department Head.” + Chr(10) + Chr(10) +"Date: " + varA + Chr(10) + Chr(10) )
'Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))
newDoc.Subject = “Notification upon Regional Manager Approval” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)
newDoc.SendTo = doc.GetItemValue(“zRequestBy”)
newDoc.Send( False )
Print “
E - Signboard Application Approval Process has been Updated
”End If
If doc.Approval(0) = “Reject” Then
varA = doc.zTempDate(0)
varB = doc.zTempDescription(0)
varC = doc.Reason(0)
varD = doc.zTempRoute(0)
zTempSign = “Department Head:” + Chr(9) + Chr(9) + varD + " (" + dateTime.DateOnly + ", " + dateTime.TimeOnly + “) - Rejected” + Chr(10) + Chr(10)
Set item = doc.GetFirstItem(“zSign”)
Call item.AppendToTextList(zTempSign)
Set newDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newDoc, “Body” )
Call rtitem.appendtext(“Please be informed that the following service request has been rejected by department head.” + Chr(10) + Chr(10) + " Date: " + varA + Chr(10) + Chr(10))
Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))
newDoc.Subject = “Notification upon Rejected Request for E - Signboard Application Rejected” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)
newDoc.SendTo = doc.GetItemValue(“zRequestBy”)
newDoc.Send( False )
Print “
E - Signboard Application Approval Process has been Updated
”End If
If doc.Approval(0) = “Route Back” Then
varA = doc.zTempDate(0)
varB = doc.zTempDescription(0)
varC = doc.Reason(0)
varD = doc.zTempRoute(0)
zTempSign = “Department Head:” + Chr(9) + Chr(9) + varD + " (" + dateTime.DateOnly + ", " + dateTime.TimeOnly + “) - Route Back” + Chr(10)+ Chr(10)
Set item = doc.GetFirstItem(“zSign”)
Call item.AppendToTextList(zTempSign)
Set newDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newDoc, “Body” )
Call rtitem.appendtext(“Please be informed that the following service request has been Route Back by department head.” + Chr(10) + Chr(10) + " Date: " + varA + Chr(10) + Chr(10))
Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))
newDoc.Subject = “Notification upon E - Signboard Application Route Back” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)
newDoc.SendTo = doc.GetItemValue(“zRequestBy”)
newDoc.Send( False )
Print “
E - Signboard Application Approval Process has been Updated
”End If
End Sub