Hi,
I have the below code being called from an XPage. The purpose of the code is to loop through selected Call Documents (numbers added to an edit box) and link the calls together…
The problem I am having is that getdocumentbykey is not working! I have changed the code to a DocCollection, but its still returning zero when the call does exist in the view. The first column of the view is sorted and when I search for the call number in the view it returns.
Can anyone shet any light on this. I have been driven demented by this and as you can see I am logging a lot - the call number before is correct with no spaces.
Please help :
%REM
Agent LinkCalls
Created Mar 16, 2010 by PMP Developer/GB/CPL/ClydePumpsLtd
Description: Comments for Agent
%END REM
Option Public
'Option Declare
Use “SequentialNumber”
Sub Initialize()
Dim s As New NotesSession
Dim db As NotesDatabase
Dim WebDoc As NotesDocument
Dim agent As NotesAgent
Dim item As NotesItem
Dim CallNo() As String
Dim strAction As String
Dim strDate As String
Dim strName As String
Dim beginningText As Variant
Dim rtnav As NotesRichTextNavigator
Dim LogAction As NotesRichTextItem
Dim OldLogAction As NotesRichTextItem
Dim strStatus As String
Dim NewDoc As NotesDocument
Dim OldDoc As NotesDocument
Dim strNewNum As String
Dim Callv As NotesView
Set db = s.CurrentDatabase
Set agent = s.CurrentAgent
Set WebDoc = db.GetDocumentByID(agent.ParameterDocID)
Set item = WebDoc.Getfirstitem("LinkCalls")
strP = item.Text
arr = Split(strP, ";")
MsgBox "----------------------------------------------------"
'MsgBox "/////////////////////////////////////////////////////"
For x = 0 To UBound(arr)
ReDim Preserve CallNo(x) As String
CallNo(x) = arr(x)
MsgBox CallNo(x)
strName = WebDoc.CurrentUser(0)
strDate = CStr(Now)
If x = 0 Then
MsgBox "Loop No : " & x
Set Callv = db.GetView("All Calls")
Set OldDoc = Callv.Getdocumentbykey(CallNo(x),True)
If Not OldDoc Is Nothing Then
MsgBox "In Here 1"
Set NewDoc = db.Createdocument()
MsgBox "In Here 1.5"
Call OldDoc.Copyallitems(NewDoc,false)
MsgBox "In Here 2"
strNewNum = GenerateSequentialNumber("FLS Call")
MsgBox "In Here 3"
NewDoc.SDNum = strNewNum
MsgBox "In Here 4"
Call NewDoc.save(True,False)
MsgBox "In Here 5"
Call db.Updateftindex(false)
Set NewDoc = Nothing
Set OldDoc = Nothing
Set Callv = Nothing
End If
Else
Call UpdateCalls(s, db, WebDoc, CallNo(x))
End If
MsgBox "Loop Here"
Next
End Sub
Sub UpdateCalls(s As NotesSession, db As NotesDatabase, WebDoc As NotesDocument, CallNo)
MsgBox "In Update Sub"
Dim v As NotesView
Dim callDoc As NotesDocumentCollection
Dim StrNum As String
Set v = db.Getview("All Calls By Number")
strNum = CallNo
MsgBox strNum
Set callDoc = v.Getalldocumentsbykey(strNum,False)
MsgBox "DOCUMENTS FOUND : " & callDoc.Count
'MsgBox "Call NO : " & CallNo
End Sub
Thank you.
F1H