Why can't we drag a customer from a customer list onto our Customer Visit Calendar and make an appointment with them that way?Good question. We already have that functionality on the web interface. Popup a customer list, select the customer or customers from the list and drag them to the day you want to schedule the visit and it auto creates the document for that customer on the day you dragged the document(s) onto.
I sucked my pencil for a bit, scratched various bits of my anatomy that would not be misconstrued by my colleagues as offensive and hummed and ahhed. I pinged Julian Robichaux and bounced the idea off him. Can I drag docs which are not calendar docs from an embedded view on a page (or form) onto calendar view embedded on the same form and create a document or documents based on the QueryDragDrop event of the calendar based on the documents that I had dropped.
Julian confirmed my initial thoughts that this was a non-runner because when a view is embedded you can't seem to access the drag drop events - BUMMER! So I then mentioned a word not mentioned in polite society much these days and to give Julian credit it didn't finch or berate me in any way. "What about Framesets?" I said
After a bit of futtering about we discovered that yes you could accecss the Drag and Drop events from FrameA to FrameB and Joy of Joys the CurrentView in the UIWorkspace FrameB's QueryDragDrop event was the view from FrameA! _ YIPEE!
I took my leave of Julian with much thanking and promises of beer and proceeded to have a bit of a debug to see what I could do.
I created a wee test NSF with two forms CUSTOMER and CALENT
Followed by a View of just the CUSTOMER forms and a Calendar view of the CALENT forms
A Frameset was created and in the LHS frame I popped CUSTOMER view and in the RHS frame CALENT calendar view.
On the CALENT view's QueryDragDrop I entered some code and had a ferret about in
what was an what was not passed, this is what I found out.
If you grab one doc from the CUSTOMER view and drop it over the calendar, then there are no documents in the UIView.Documents collection, there is a CaretNoteID that links to the dragging document in the UIView.
If you select more than one document from the CUSTOMER view and drag it over the Calendar then the UIView.documents collection contains the documents you selected.
If you actually select (the wee tick in the gutter) one document the UIView.documents will contain that one document, but you cannot count on users doing that.
Sub Querydragdrop(Source As Notesuiview, Continue As Variant)
Dim ThisSession As New NotesSession
Dim ThisDB As notesdatabase
Dim ThisUI As New NotesUIWorkspace
Dim ThisUIV As NotesUIView
Dim ThisDC As notesdocumentcollection
Dim OldDoc As NotesDocument
Dim NewDoc As NotesDocument
Set ThisDB = ThisSession.CurrentDatabase
Set ThisUIV = ThisUI.CurrentView
' *** Test to see if the view I am dragging from is the calendar or the customer list
If ThisUIV.ViewName <> "Calendar" Then
Set ThisDC = ThisUIV.Documents
'*** Well you must have dragged SOMETHING to fire the event so get it from
'*** from the CaretNoteId
If ThisDC.Count = 0 Then
Set OldDoc = ThisDB.getDocumentById(ThisUIV.CaretNoteID)
Set NewDoc = New NotesDocument(ThisDB)
NewDoc.Form = "CalEnt"
NewDoc.Customer = OldDoc.Customer(0)
NewDoc.City = OldDoc.City(0)
NewDoc.Date = Source.CalendarDateTime
NewDoc.Time =Format(Now,"hh:mm")
NewDoc.Status = "Planned"
Call NewDoc.Save(True,False)
Else
Set OldDoc = ThisDC.GetFirstDocument
Do While Not (OldDoc Is Nothing)
Set NewDoc = New NotesDocument(ThisDB)
NewDoc.Form = "CalEnt"
NewDoc.Customer = OldDoc.Customer(0)
NewDoc.City = OldDoc.City(0)
NewDoc.Date = Source.CalendarDateTime
NewDoc.Time =Format(Now,"hh:mm")
NewDoc.Status = "Planned"
Call NewDoc.Save(True,False)
Set OldDoc = ThisDC.GetNextDocument(OldDoc)
Loop
End If
Else
'*** This is the calendar and I am moving docs around inside it
Set ThisDC = ThisUIV.Documents
If ThisDC.Count = 0 Then Exit Sub
Set OldDoc = ThisDC.GetFirstDocument()
Do While Not (OldDoc Is Nothing)
OldDoc.Date = Source.CalendarDateTime
Call OldDoc.Save(True,False)
Set OldDoc = ThisDC.GetNextDocument(OldDoc)
Loop
End If
Call ThisUI.ReloadWindow()
End Sub
This code allows the user to drag a customer (with or without tick selction) or customers from the customer list in the left hand frame onto the calendar and create a calendar entry for that customer on the dropped on date. The user can also safely drag and drop calendar entries around inside the calendar.
Useful and cool. :-)
I have popped the NSF up here so if you are interested in seeing it in action you can have a go.
Enjoy ...