Agent not creating documents when scheduledThis agent run and works as expected when it is ran from the actions menu, but when I set it to run scheduled, it runs and sets information in the original doc but it doesn’t create the new document. Any thoughts
Sub Initialize
Set s = New Notessession
Dim db As Notesdatabase
Set db = s.CurrentDatabase
Dim sview As NotesView
Dim count As Integer
Dim n As Integer
Dim m As Integer
Dim newDoc As NotesDocument
Dim studentID As Variant
Dim GlDate As Variant
Dim groupsingledoc As Variant
Dim newstudentID As Variant
Dim CurrentStudentID As Variant
Dim groupNumMeeting As Variant
Dim PosTimeCount As Variant
Dim PosGiTime As Variant
Dim currentSRUnid As Variant
Dim item As NotesItem
Dim item2 As NotesItem
Set sview = db.GetView( "GLSM" )
Set doc =sview.GetFirstDocument
While Not(doc Is Nothing)
For m = 1 To 19
For n = 1 To 45
studentId = doc.GetItemValue( "GlStudent_" + Cstr ( n ))
'**new create field switch "No" | "Yes" **
groupsingledoc = doc.GetItemValue( "GlSingleCreate_" + Cstr ( m ))
studentIdCreated = doc.GetItemValue( "StudentGlCreated_" + Cstr ( n ))
Gldate = doc.GetItemValue( "GlDate_" + Cstr ( m ))
PosGiTime = doc.GetItemValue( "D1_PosGiTime_" + Cstr ( m ))
StudentActTime = doc.getitemValue("D"+ Cstr ( m )+"_GiTime_" + Cstr ( n ))
newstudentID = doc.GetItemValue( "GlStudent_" + Cstr ( n ))
curStudentID = ( "GlStudent_" + Cstr ( n ))
curStudentCreated = ( "StudentGlCreated_" + Cstr ( n ))
groupNumMeeting = Cstr ( m )
'Count = m - 1
'PosTimeCount = Count
'******* Test to see if date document has been created 10-24-05********
If groupsingledoc(0) = "NO" And GlDate(0) <> "" And studentId(0) <> "" Then
Set item2 = doc.ReplaceItemValue( "GlSingleCreate_" + Cstr ( m ), "No" )
'If groupsingledoc(0) = "No" And GlDate(0) <> "" And studentId(0) <> "" Then
Set newDoc =db.CreateDocument
newDoc.Form = "GroupLogSingleMeeting"
currentSRUnid = newdoc.UniversalID
newdoc.GLSMSite = doc.GLSite(0)
newdoc.GLSMStaffName = doc.GLStaffName
newdoc.GLSMTitle = doc.GLTitle(0)
newdoc.ContGLSMTitle = doc.ContGLTitle(0)
newdoc.GLSMSchoolYear = doc.GLSchoolYear(0)
newdoc.GLSMNumber = doc.GLNumber_1(0)
newdoc.groupNumMeeting = groupNumMeeting
newdoc.GLSMType = doc.GLType(0)
newdoc.GLSMNumber_1= doc.GLNumber_1(0)
newdoc.GLSMTypeOther = doc.GLTypeOther(0)
newdoc.GLSMGroupNum = doc.GLGroupNum(0)
newdoc.NonConsentSM = doc.NonConsent(0)
newdoc.NumNonConsentSM= doc.NumNonConsent(0)
newdoc.GlRNumConsent = doc.NumConsent(0)
newdoc.Gldate = Gldate(0)
'student specific informationGLSMStudentActTime
newdoc.GlSMStudent = newStudentID
currentSSMUnid = newdoc.UniversalID
newdoc.GlRSPUNID = doc.GetItemValue( "GlSPUID_" + Cstr ( n ))
UserTotal = doc.GetItemValue( "UserTotal_" + Cstr ( n ))
newdoc.GLTIMER = UserTotal
newdoc.GLSMPossibleTime = PosGiTime(0)
newdoc.GLSMStudentActTime = StudentActTime(0)
'this is the new change
newdoc.PUnid = doc.UniversalID
newdoc.GlSMFirstDate = doc.GlDate_1(0)
newdoc.GlSMLastDate = doc.GlLastGroup(0)
'students time in group
UserTotal = doc.GetItemValue( "UserTotal_" + Cstr ( n ))
SessMissed = doc.GetItemValue( "TotalGlMissSessStud_" + Cstr ( n ))
newdoc.GLSRNumMissSess = SessMissed
'****************save doc ************************
Call newdoc.ComputeWithForm( False, False )
Call newdoc.save( True, True )
Call doc.save(True, True)
Elseif studentid(0) = "" And Gldate(0) <> "" Then
Goto NextM
Elseif studentid(0) ="" And Gldate(0) = "" Then
Set item2 = doc.ReplaceItemValue( "GlSingleCreate_" + Cstr ( m ), "NO" )
Goto NextX
'***********save doc ************************
'doc.GLSRCreated(0) = "Yes"
Call newdoc.ComputeWithForm( False, False )
Call newdoc.Save(False, False)
End If
Next
NextM: Set item2 = doc.ReplaceItemValue( “GlSingleCreate_” + Cstr ( m ), “YES” )
Next
NextX: Call doc.save(True, True)
Set doc = sview.GetNextDocument(doc)
Wend
End Sub