[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Repeat function not working on the DeverloperWorks "Build a Conference Room Res Sys." database

Posted on 2007-07-25
6
Medium Priority
?
206 Views
Last Modified: 2013-12-18
I used the "Build a Conference Room Reservation System" database from Developer's toolbox and find that when I try to repeat my event throughout the calendar, it's not working.  Even though I sat up the event to repeat daily for a month, the event only displays for one day (the initial entry).  Is something wrong with the script?
0
Comment
Question by:kat64
5 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 19570195
Not sure, post the script.


I hope this helps !
0
 

Author Comment

by:kat64
ID: 19570331
Ok...this is the whole Repeat Script Library


Dim session As NotesSession
Dim db As notesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim docA As NotesDocument
Dim docB As NotesDocument
Dim x As Integer
Dim y As Integer
Dim i As Integer

Sub Initialize
      
      Dim workspace As New NotesUIWorkspace
      Set session = New NotesSession
      Set db = session.CurrentDatabase
      
End Sub

Sub RepeatDaily (DocRef As NotesDocument)
      
      Dim workspace As New NotesUIWorkspace  
      Dim dtWeekend As Integer
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      
      ' Msgbox "Repeat on daily basis."
      Dim dtValue As New NotesDateTime( docA.StartDate(0) )
      x% = docA.RepeatDateDiff(0)
      
      For i = 1 To x
            Call dtValue.AdjustDay( i )
            dtWeekend = Weekday ( dtValue.DateOnly )
            If dtWeekend = 1 Or dtWeekend = 7 Then
                  Select Case docA.RepeatWeekends(0)
                  Case "X"  : REM "place holder for future use"
                  Case "D"  : Call CreateRepeatEntry ( dtValue.DateOnly, DocRef )      
                  Case "F"  : REM "place holder for future use"
                  Case "M"
                        If dtWeekend = 7 Then
                              If x < i+2 Then
                                    Call dtValue.AdjustDay( 2 )
                                    Call CreateRepeatEntry ( dtValue.DateOnly, DocRef )
                                    Call dtValue.AdjustDay( -2 )
                              End If
                        End If
                  Case Else : Msgbox "We should not be here... (RepeatDaily)"
                  End Select
            Else
                  Call CreateRepeatEntry ( dtValue.DateOnly, DocRef )                
            End If
            Print "Creating repeat reservations... ( " & i & " of " & x &  ")"
            Call dtValue.AdjustDay( -i )
      Next
      
End Sub

Sub RepeatWeekly (DocRef As NotesDocument)
      
      Dim workspace As New NotesUIWorkspace  
      Dim dtWeekday As Integer
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      
      ' Msgbox "Repeat on weekly basis."
      Dim dtValue As New NotesDateTime( docA.StartDate(0) )
      x% = docA.RepeatDateDiff(0)
      For i = 1 To x
            Call dtValue.AdjustDay( i )
            dtWeekday = Weekday ( dtValue.DateOnly )                                                      
            Forall d In docA.RepeatAdjust_W                                                                        
                  If d = Cstr( dtWeekday - 1) Then Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
            End Forall                                                                                                                   
            Call dtValue.AdjustDay( -i )                                                                                         
      Next
      
End Sub

Sub RepeatMonthlyDay (DocRef As NotesDocument)
      
      Dim workspace As New NotesUIWorkspace
      Dim dtWeek As Integer
      Dim dtWeekday As Integer
      Dim dtDay As Integer
      Dim tmpDate As String      
      Dim indicator As String
      Dim category As NotesItem
      
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      Set category =  docA.GetFirstItem ("RepeatAdjust_MP")
      tmpDate$ = Month(docA.StartDate(0)) & "/01/" & Year(docA.StartDate(0))
      Dim dtValue As New NotesDateTime( tmpDate$ )
      
      ' Msgbox "Repeat on monthly by day basis."
      dtWeek = 1          
      Do Until Cdat (dtValue.DateOnly) > Cdat (docA.RepeatUntil(0))
            dtWeekday = Weekday ( dtValue.DateOnly )
            For dtDay = 0 To 6
                  indicator = dtWeek & "." & (Weekday(dtValue.DateOnly) -1)
                  If category.Contains( indicator ) Then
                        If Datevalue(dtValue.DateOnly) > Datevalue(docA.StartDate(0)) Then
                              Call CreateRepeatEntry ( dtValue.DateOnly, DocRef )                  
                        End If
                  End If
                  Call dtValue.AdjustDay( 1 )
                  If Day (dtValue.DateOnly) = 1 Then
                        dtWeek = 0
                        Exit For
                  End If
            Next
            dtWeek = dtWeek + 1
      Loop
      
End Sub

Sub RepeatMonthlyDate   (DocRef As NotesDocument)
      
      Dim workspace As New NotesUIWorkspace
      Dim dtWeek As Integer
      Dim dtWeekday As Integer
      Dim dtDay As Integer
      Dim tmpDate As String      
      Dim Indicator As String
      Dim category As NotesItem
      
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      
      ' Msgbox "Repeat on monthly by date basis."
      Dim dtValue As New NotesDateTime( docA.StartDate(0) )
      x% = docA.RepeatDateDiff(0)
      For i = 1 To x      
            Call dtValue.AdjustDay( i )
            Forall d In docA.RepeatAdjust_MD
                  dtDay = Day ( dtValue.DateOnly )
                  If Cint(d) = dtDay Then
                        dtWeekend = Weekday ( dtValue.DateOnly )
                        If dtWeekend = 1 Or dtWeekend = 7 Then
                              Select Case docA.RepeatWeekends(0)
                              Case "X"  : Continue = 1
                              Case "D" : Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
                              Case "F"  : Continue = 1
                                    Set dtRange = docA.GetFirstItem( "RepeatAdjust_MD" )                              
                                    If dtWeekend = 1 Then
                                          Call dtValue.AdjustDay( -2 )
                                          ddd$ = Day ( dtValue.DateOnly )
                                          If Not dtRange.Contains( ddd$ ) Then Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
                                          Call dtValue.AdjustDay( 2 )
                                    Else
                                          Call dtValue.AdjustDay( -1 )
                                          ddd$ = Day ( dtValue.DateOnly )
                                          If Not dtRange.Contains( ddd$ ) Then Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
                                          Call dtValue.AdjustDay( 1 )
                                    End If
                              Case "M"
                                    Set dtRange = docA.GetFirstItem( "RepeatAdjust_MD" )
                                    If dtWeekend = 1 Then
                                          Call dtValue.AdjustDay( 1 )
                                          ddd$ = Day ( dtValue.DateOnly )
                                          If Not dtRange.Contains( ddd$ ) Then Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
                                          Call dtValue.AdjustDay( -1 )
                                    Else
                                          Call dtValue.AdjustDay( 2 )
                                          ddd$ = Day ( dtValue.DateOnly )
                                          If Not dtRange.Contains( ddd$ ) Then Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
                                          Call dtValue.AdjustDay( -2 )
                                    End If
                              Case Else : Msgbox "We should not be here... (RepeatMonthlyDate)"
                              End Select
                        Else
                              Call CreateRepeatEntry ( dtValue.DateOnly, DocRef)
                        End If
                        Exit Forall
                  End If              
            End Forall
            Call dtValue.AdjustDay( -i )
      Next
      
End Sub

Sub RepeatCustom (DocRef As NotesDocument)
      
      Dim workspace As New NotesUIWorkspace    
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      
      ' Msgbox "Repeat on custom basis."  
      x = 1
      y = Ubound(docA.RepeatDates) + 1
      Forall i In docA.RepeatDates
            Print "Creating repeat reservations... ( " & x & " of " & y &  ")"
            Call CreateRepeatEntry ( i, DocRef)
            x = x + 1
      End Forall
      
End Sub

Sub ProcessRepeatType (DocRef As NotesDocument)
      
      Dim workspace As New NotesUIWorkspace    
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      
      If docA.RepeatUnit(0) <> "" Then
            Select Case docA.RepeatUnit(0)
            Case "D" :      Call RepeatDaily (DocRef)
            Case "W" :     Call RepeatWeekly (DocRef)
            Case "MP"  :  Call RepeatMonthlyDay  (DocRef)
            Case "MD" :   Call RepeatMonthlyDate  (DocRef)
            Case "C" :      Call RepeatCustom  (DocRef)
            Case Else:      Msgbox "Repeat Unit error in ScriptLibrary"
            End Select
            Print "Repeat reservations complete"  
      End If
      
End Sub

Sub DisplayRepeatDialog
      
      Dim workspace As New NotesUIWorkspace
      Set uidoc = workspace.CurrentDocument
      Set doc = uidoc.Document
      Call workspace.DialogBox( "(Res)", True, True, , , , , "Repeat Reservation" )    
      
End Sub

Sub CreateRepeatEntry ( RepeatDateValue As Variant , DocRef As NotesDocument)    
      
      Dim workspace As New NotesUIWorkspace    
      Dim dateRange As NotesDateRange
      Dim sdate As String
      Dim repeatDate As String      
      Dim date1 As NotesDateTime
      Dim theRepeatDate As NotesDateTime
      Dim theStartDate As NotesDateTime
      Dim rStartDate As String
      
      Set uidoc = workspace.CurrentDocument  
      Set docA = uidoc.Document
      Set docB = New NotesDocument( db )
      Set dateRange = session.CreateDateRange()    
      
      '-----------------------------------------------------    
      ' Make copy of original reservation
      '-----------------------------------------------------    
      Call docA.CopyAllItems( docB, True )    
      
      '-----------------------------------------------------    
      ' Change the date on the new repeat entry    
      '-----------------------------------------------------    
      dateRange.Text = uidoc.FieldGetText( "TimeRange" )
      sdate$ = Datevalue ( RepeatDateValue ) & " " & dateRange.StartDateTime.LocalTime
      Set date1 = New NotesDateTime( sdate$ )
      docB.StartDateTime = date1.LSLocalTime
      docB.StartDate = date1.LSLocalTime
      
      '-----------------------------------------------------
      ' Cleanup/Reset various data fields
      '-----------------------------------------------------
      docB.RemoveItem("Invite")
      docB.ReservationStatus = "CLOSED"
      Call docB.Save( True, True, True )
      
      '-----------------------------------------------------
      ' Set the "repeat date instances" in the main record.
      ' Required to process repeat appt in LN email client.
      '-----------------------------------------------------
      Dim oldArray
      Dim newArray() As Variant
      rStartDate$ = Datevalue (DocRef.StartDate(0)) & " " & docRef.Time1(0)
      Set theStartDate = New NotesDateTime ( rStartDate$ )
      repeatDate$ = Datevalue (RepeatDateValue)  & " " & docRef.Time1(0)
      Set theRepeatDate = New NotesDateTime ( repeatDate$ )
      If DocRef.RepeatInstanceDates(0) = "" Then DocRef.RepeatInstanceDates = theStartDate.LSLocalTime
      oldArray = docRef.RepeatInstanceDates
      Redim Preserve newArray(Ubound(oldArray)+1)
      newArray(0) = theRepeatDate.LSLocalTime
      For x = 1 To Ubound(newArray)
            newArray(x) = oldArray(x-1)            
      Next
      docRef.RepeatInstanceDates = newArray
      
End Sub

Function CheckFieldValues ( DocRef As NotesDocument )
      
      CheckFieldValues = True
      MsgText = ""
      If DocRef.Topic(0) = "" Then
            MsgText = MsgText + "Specify a topic." + Chr$(13)
      End If
      
      If DocRef.StartDate(0) = "" Then
            MsgText = MsgText + "Specify a start date." + Chr$(13)
      End If
      
      If DocRef.Time1(0) = "" Then
            MsgText = MsgText + "Specify a start time." + Chr$(13)
      End If
      
      If DocRef.Time2(0) = "" Then
            MsgText = MsgText + "Specify an end time." + Chr$(13)
      End If
      
      If MsgText <> "" Then
            Msgbox MsgText,16,"Required Fields."
            CheckFieldValues = False
      End If
      
End Function
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 19570710
The script in general looks OK.

I would check the calendar view info. Something may not be correct there.

Also make sure that you replace the design from the original if you made any changes, as a test.


I hope this helps !
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 19571521
Rather than post the whole script,  a link would have sufficed. Hard to scroll through this :(

Anyway, do a field dump of the resulting calendar entry and post that -- even if it gets long :)
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19902294
PAQed with no points refunded (of 500)

Computer101
EE Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question