@Return(@Prompt([Ok];“Duplicate”;“You are already subscribed for this building.”));“”
);
@All;
SELECT @All
searching saved documents for 2 sets of matching fields, matching inputted fields "Subscribe_E_Mail & Subscribe_Building and if theyre found, storing them in hidden fields, and if hidden fields have information, showing a message box. Clearly a java programmer by nature, can someone direct me in the right direction, thanx.
Where are you using this code, exactly? The SELECT statement is throwing me, since this makes it look like a disastrously constructed view selection formula.
I put this code in an agent. I only want to look at 2 fields a user entered onto a form, and then search the DB for a document that has both of those values, if one is found, displaying a message box.
& is a logical operator. A & B != “” means (A is true) and (B != “”). Since presumably the email address is a string, the result of your lookup is not a logical value; you’ll get an error here.
How is the Subscribers view sorted? You can only use @DbLookup to search a view for the values in the first sorted column. Does the first sorted column contain the email and the building?
@DbLookup doesn’t return “” if the key is not found; it throws an error. There’s an argument [FailSilent] to make it return “”. Read about it.
Even if it were expressed correctly, your logic is flawed. If there’s a record that matches the email, and there’s a record that matches the building, what’s to say that they’re the same record?
You don’t really have fields in your documents named Duplicate_E_Mail and Duplicate_Building, do you? When someone enters an email address on a form, it’s not their duplicate email – it’s just their email.
Here’s an idea. If your view is sorted by email, and there’s a column in the view (column 3, let’s say) that contains the building, then you could do this:
Suggest you use LotusScript the onload event of the form and check against a view where your sorted column is a concatenation of the email and building values. This would eliminate your need to have hidden fields.
Sub Onload(Source As Notesuidocument)
If Source.isNewdoc Then
start:
email = Inputbox$("specify email", "email")
building = Inputbox$("specify building", "building")
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim v As NotesView
Set v = db.GetView( "test123" )
Dim key As String
key = Ucase(email & building)
Set doc = v.GetDocumentByKey( key, True )
If Not(doc Is Nothing) Then
answer = Messagebox("A document with this mail and building already exists, would you like to discard this new document and switch to that document?",4,"title")
If answer = 6 Then
Dim ws As New NotesUIWorkspace
Call ws.EditDocument(False, doc)
Else
Goto start
End If
Else
Call source.fieldsettext("email",email)
Call source.fieldsettext("building",building)
End If
End If