Solved

calendar

Posted on 2006-06-15
9
363 Views
Last Modified: 2013-12-18
Hi all,

If possible, i would like to have a bit of help with the following:

The ability to prompt a user when they drag a calendar entry from one time slot to another with a prompt to ask if they would like to move all other entries related with this entry.
All entries related entries are within a multivalue date field which is populated in the calendar when the document is created.
For example, datefield will have:10/12/2005, 10/12/2006,  10/10/2006.......any many others and they are relating to the one product document.
If I decide to move 10/122005 by dragging it in the calendar view 3 days forward, then I want to be prompt whether or not I need to move the others too, if I answer "yes" then all other entries(in this case 2 other entries) will also move 3 days forward. If I answer no, then only this one entry which I have just dragged should move forward and others should stay the same.

Is this possible?
0
Comment
Question by:varvoura
  • 5
  • 4
9 Comments
 

Author Comment

by:varvoura
ID: 16925374
OK,

I have worked out the script for this, however, I am having a small problem with the first entry in the loop.

My loop does the following:

prompts the user if they want to change all other entries according with this change
if yes, then changes all the entries in the date field in accordance to the difference between the enddate and startdate of this change.

THE ONLY PROBLEM is:

It is also changing the current entry which is already changed, so the selected entry is changed twice and every other entry in the loop is changed OK.

Ideas??
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16934412
Hmm, was thinking perhaps exclude any entries from your loop which is the new value already?  But then how does this handle it when you drag something that has entries for:

12-Jan
13-Jan
14-Jan

to 13-Jan though?  i.e. 12-Jan would move to 13-Jan, 13-Jan would then be ignored and 14-Jan would move to 15-Jan.

Can you post your current event handling code...

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16934432
Ahh, how about:  Store a copy of the date field in your document as a calculated field, value as itself or hidden editable field.

In your event use this other field to add the difference of the other two dates to each element then write that back to your main field.  You'd have to update this field at any other time the main field can change too such as any submit or save buttons or other agents which manipulate the dates though.

Steve
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:varvoura
ID: 16940757
Hi Steve,

Here's the code, I prefer that things are handled in the second forall loop that I have instead of creating other fields on the document, there's enough computed & hide when on that document to keep the world confused so if it can be done without additional form field it will be best.

Dim session As New NotesSession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      
      Dim uiw As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Set uidoc = uiw.CurrentDocument
      Dim doc As NotesDocument
      Set doc = db.GetDocumentByID( source.CaretNoteID )
      
      
        Dim fromList As Variant
      Dim tmpList As Variant
      Dim toList As Variant
      Dim oldList() As String
      Dim newList As Variant
      Dim diff As Variant
      
      
      SelectedDate = uiw.CurrentCalendarDateTime
      
      fromDate = Cstr( Datevalue(uiw.CurrentCalendarDateTime ) )    
      toDate = Cstr( source.CalendarDateTime )
      
      fromDate = Left( fromDate, Len( fromDate) )
      toDate = Left( toDate, Len( toDate ))
      Dim date3 As Variant
      date3 = Cdat(todate) - Cdat(fromdate)
      
      tmpList =doc.docdatefield
      
      i=0
      
      Forall x In tmpList
            Redim Preserve oldList(i)
            oldList(i) = Format$(x, "Short Date")
            i = i + 1
      End Forall
      
      fromList = MakeArray( fromDate )
      toList = MakeArray( toDate )
      
      newList = Arrayreplace(oldList, fromList, toList )
      
      Dim askme As Integer
      askme = uiw.Prompt (PROMPT_YESNO, _
      "Test Schedule", "Would you like to move all other entries ?")
      
      Dim newlist1 As Variant
      newlist1 = newlist
      
      i = 0
      Forall x In newList1
            
            Redim Preserve newlist(i)
            If askme = 1 Then
                  
                  newlist(i) = Cdat(x) + date3
            Else
                  newlist(i)  = Cdat(x)
                  
            End If
            
            i = i+1
            
      End Forall
      
      doc.docdatefield= newList
      Call doc.Save( True, True, True )
      Call uiw.ViewRefresh
      
End Sub


I have also tried the following:

Created a selecteddate field where I picked up the document current time  and I tried in the loop to check with the value of x, if x <> selected value then newlist(i) = Cdat(x) + date3, Else newlist(i) = cdat(x), didn't work

I've also tried to place the following code in loop under just after the first line of the second forall statement:

I tried to compare x to todate to exclude that entry that matched todate from the loop or add only cdat(x) instead of cdat(x) + date3 to it.

So anyway at this stage both of my attempts were unsuccessful so I'd really appreciate your help if possible.

Thanks for your prompt responses
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16947024
OK looks like you are replacing the old date with new then doing the move for the whole array again.  Best bet is to just do it once.  Something like this:

Apologies for any typos.

Steve



Dim session As New NotesSession
     Dim db As notesdatabase
     Set db = session.currentdatabase
     
     Dim uiw As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = uiw.CurrentDocument
     Dim doc As NotesDocument
     Set doc = db.GetDocumentByID( source.CaretNoteID )
     
     
       Dim fromList As Variant
     Dim tmpList As Variant
     Dim toList As Variant
     Dim oldList() As String
     Dim newList As Variant
     Dim diff As Variant
     
     
     SelectedDate = uiw.CurrentCalendarDateTime
     
     fromDate = Cstr( Datevalue(uiw.CurrentCalendarDateTime ) )    
     toDate = Cstr( source.CalendarDateTime )
     
     fromDate = Left( fromDate, Len( fromDate) )
     toDate = Left( toDate, Len( toDate ))
     Dim date3 As Variant
     date3 = Cdat(todate) - Cdat(fromdate)
     
     tmpList =doc.docdatefield
     
     i=0
     
     Forall x In tmpList
          Redim Preserve oldList(i)
          oldList(i) = Format$(x, "Short Date")
          i = i + 1
     End Forall
     
     fromList = MakeArray( fromDate )
     toList = MakeArray( toDate )
     
     Dim askme As Integer
     askme = uiw.Prompt (PROMPT_YESNO, _
     "Test Schedule", "Would you like to move all other entries ?")

     Dim newlist1 As Variant
     if askme=1 then
         newlist1 = oldlist
         i = 0
         Forall x In newList1
            Redim Preserve newlist(i)
            newlist(i) = Cdat(x) + date3
            i = i+1
         End Forall
   else
      newList1 = Arrayreplace(oldList, fromList, toList )
         i = 0
         Forall x In newList1
            Redim Preserve newlist(i)
            newlist(i) = Cdat(x) + date3
            i = i+1
         End Forall

   end if
     
     doc.docdatefield= newList
     Call doc.Save( True, True, True )
     Call uiw.ViewRefresh
     
End Sub
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 16947038
You'll want to remove the + date3 from the last loop, left in during paste.
0
 

Author Comment

by:varvoura
ID: 16957860
Super, thank you Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16957925
No problem, thanks for the points.

Steve
0
 

Author Comment

by:varvoura
ID: 16958189
My pleasure.

Vavoura
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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