Solved

calendar

Posted on 2006-06-15
9
358 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now