Ok, let’s go. Could u folks help me with this?
I’m doing an agente that makes a validation to compare if the field’s value is already at the database when user submit a form.
The problem is when the user subcribes a new form or edit the current doc. My agent doesn’t work very well and show the messagebox: “This doc is already at the database” and after removes the doc…
I’m trying to do the IF verification usign ISNEWDOC, but I don’t know if it’s possible.
Here’s follow the code.
Thanks is advance.
Function VALIDA(DOC As notesdocument) As Boolean
On Error GoTo TrataErro
VALIDA = False
MsgBox "iniciiooooooooooo"
Dim session As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Set Websession = New NotesSession
Set Webdoc = Websession.DocumentContext
Set db = Websession.CurrentDatabase
MsgBox doc.Form(0)
If doc.Form(0) = "frmSites" Or doc.Form(0) = "Cadastro de Sites" Then
bscParam = {(form = "Cadastro de Sites") | (form = "frmSites") & (flag_delet = "0") & fld_site ="} & doc.fld_site(0) & {" & fld_codigo ="} & doc.fld_codigo(0) & {"}
MsgBox bscParam
End If
If doc.Form(0) = "frmNotesServer" Or doc.Form(0) = "Cadastro de NotesServer" Then
bscParam = {(form = "Cadastro de NotesServer") | (form = "frmNotesServer") & (flag_delet = "0") & fld_notesServer ="}& doc.fld_notesServer(0) & {" & sites_server ="} & doc.sites_server(0) & {"}
MsgBox bscParam
End If
Set col = db.Search(bscParam, Nothing, 0)
MsgBox CStr(col.Count )+ "*?*"
If col.Count = 0 Then
VALIDA = False
Else
VALIDA = True
End If
Exit function
TrataErro:
Dim Linha As Integer
Dim MsgErr As String
Dim NumErr As Integer
Linha% = Erl()
MsgErr = Error
NumErr = Err
MsgBox "<<< Erro (Agt: Salvar Fnc: Initialize): " & MsgErr & ". Linha " & CStr(Linha) & " >>>"
End Function