Here is a very strange situation; I do not recall ever seeing this behaviour with LotusScript in any version prior to ND6.Basically, A given function will return a proper object handle when used inside the same lotusScript library, but that handle will be lost when the function is called from outside the library. (for instance, when called from a view action script , through a Use Library statement)
Here are the gory details:
INSIDE a script library, we have a FUNCTION which is set to return a handle to a NotesDocument:
Function GetSecurityProfile (CompanyCode As String) As NotesDocument
'..... several lines of code snipped
Set GetSecurityProfile = ..... 'proper final assignment in order to return the correct handles
End Function
This function works perfectly, and the debugger confirms that the proper document handle is returned.
Now, let’s call this function from a view action:
(Options)
Use “SecurityAccounts”
Click
Sub Click(Source As Button)
Dim wk as New NotesUIWorkspace
Dim doc As NotesDocument
Set doc = GetSecurityProfile (CustomerKey) 'assumes CustomerKey is correctly assigned
If doc Is Nothing Then
Messagebox "Error: " & CustomerKey & " not found!"
Exit Sub
End If
Call wk.editDocument (False, doc)
End Sub
The debugger confirms that, WHILE INSIDE the GetSecurityProfile function, the proper handle is returned.
But once we leave the function and return to the calling script, the handle is set to Nothing.
Of course, I can force the full function to be a STATIC function, and then it works, but that’s quite messy and in addition, It seems I never had this kind of behaviour in the past version.
Can someone advise?
Thank you
Nicolas Abesdris