I am using the DBDesign classs originally from Damien Katz and then modified by Aaron Oneal to include a compile function. I can’t get the compile function to work. Here it is from the class
Public Function compile( doc As NotesDocument ) As Integer
Dim aUnid As UNID
Dim hNote As Long
Call ExtractUnid(doc.UniversalId, aUnid)
CheckError(WinNSFNoteOpenByUNID(dbhandle, aUnid,0,hNote))
CheckError(WinNSFNoteLSCompile(dbhandle,hNote,0))
CheckError(WinNSFNoteSign(hNote))
CheckError(WinNSFNoteUpdate(hNote,0))
CheckError(WinNSFNoteClose (hNote))
End Function
When I comment out the WinNSFNotesCompile line, everything works and the agent is signed. However when I leave it in I get a 222 or “Note not found” error. Any ideas?
Subject: Solution
I found the solution to the problem. Since I looping through DBDesign.agentDocuments and DBDesign.scriptLibraryDocuments of the DBDesign class and then calling DBDesign.compile, I was attempting to compile Simple and Formula Agents. I changed the code in my version of DBDesign to check the $Flags field to see if the agent or script was a LotusScript agent.
Public Function compile( doc As NotesDocument ) As Integer
Dim aUnid As UNID
Dim hNote As Long
Call ExtractUnid(doc.UniversalId, aUnid)
CheckError(WinNSFNoteOpenByUNID(dbhandle, aUnid,0,hNote))
If Instr(doc.GetItemValue("$Flags")(0),"L")>0 Then
CheckError(WinNSFNoteLSCompile(dbhandle,hNote,0))
End If
CheckError(WinNSFNoteSign(hNote))
CheckError(WinNSFNoteUpdate(hNote,0))
CheckError(WinNSFNoteClose (hNote))
End Function
Now it works for compiling any agent or ScriptLibraries.