New ResponseCancelCopy to Archive Copy to ArchiveMove to Archive Move to Archive


Document Library
Main Topic

Kurt Tomicich
2005/02/15


Procedure
Reference
Subject:Validate a field as unique On Save
Category:Tips\ Notes\ Programming
Version:
Revision Date:2005/02/15 Modified: 2005/03/07
 
Reviewers
OriginatorPreviousCurrentFuture
Kurt TomicichKurt Tomicich/KRTNoneNone
The field being validated must appear in a view, in position 1, as a simple "display the value in field *" - no formulas allowed for the column.

Set the Form's QuerySave object to the following script (Change Red text to your appropriate entries) :

1. Have a field called Doc_ID on your form, Computed when composed, set to @Unique
2. Make a view with the columns ...
3.
Office_IP +"-" + MachineIP (Sorted)
4.
Doc_ID
5. Put the following in the
QuerySave method

' This tests a key field on a view. If they match, and it's not the same document, it's an error

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry

Continue = True
Set db = session.CurrentDatabase

Set view = db.GetView(
view-name)
Set entry = view.GetEntryByKey(
Office_IP +"-" + MachineIP, True )

If Not (entry Is Nothing) Then
view_id = entry.ColumnValues(1)
If view_id <> doc.Doc_ID(0) Then
msgbox "This IP was used in another document for this office"
Continue = False
End If
End If
End If





Submitted for review on 2/15/2005
Review completed by Kurt Tomicich on 3/7/2005


All Documents   By Author   By Category   By Alternate Name   Review Status   Help