Domino 9 und frühere Versionen > ND6: Entwicklung

während Eingabe überprüfen, ob Wert bereits in der DB vorhanden ist

<< < (3/4) > >>

alexbeer:
Danke für die Aufklärung...
Mit
--- Code: ---Sub Exiting(Source As Field)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Call uidoc.Refresh
End Sub
--- Ende Code ---

habe ich das dann aber auch behoben!

MadMetzger:
Kann man dafür nicht auch eine Maskeneigenschaft setzen, die das grundsätzlich macht? Die hieß doch irgendwie "Felder automatisch aktualisieren bei...", oder täusche ich mich da jetzt?

koehlerbv:
Du täuschst Dich da nicht, Markus, aber diese Property will mit grosser Bedacht eingesetzt werden, da bei vielen Feldern und vor allem, wenn auch noch Lookups oder ähnliches stattfinden, die Performance dramatisch in die Knie gehen kann.

Die bislang geposteten Snippets haben einen Nachteil: Sie schlagen auch zu, wenn man das Unikat nach erneuter Bearbeitung erneut speichern will.

Ich biete mal eine Function aus einer meiner StandardLibs an. ACHTUNG: Die Sub ErrorHandler und die Konstante MSG_INFORM_ADMIN sind selbst zu zu schreiben / zu definieren.

Bernhard



--- Code: ---Function IsValueAmbiguous (szLookupViewName As String, docCurrent As NotesDocument, szValue As String, szErrorMessage As String) As Integer
'==================================================================================================================
' Purpose: Checks in the given view if the specified value exists more than one time. Empty strings won't be checked.
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Arguments:
' szLokkupViewName - the name of the view to search in
' docCurrent - the NotesDocument the value resides in
' szValue - the value which isn't allowed to be ambiguous
' szErrorMessage - will keep possible error messages (for server based routines calling this function)
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Returns: True, if the value exists more than one time
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Created by:  Bernhard Koehler on 01.06.2004            Modified by: Bernhard Koehler on 13.01.2005
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Changes: BK on 13.01.2005 - There was no setting to False if no ambiguous value was found !
'==================================================================================================================

Dim session As New NotesSession
Dim dbCurrent As NotesDatabase
Dim viewLookup As NotesView
Dim collFound As NotesDocumentCollection
Dim docFound As NotesDocument

On Error Goto ErrorRoutine

IsValueAmbiguous = True

'Instantiate the current database and the lookup view:
Set dbCurrent = session.CurrentDatabase
Set viewLookup = dbCurrent.GetView (szLookupViewName)
If viewLookup Is Nothing Then
szErrorMessage = "Die Ansicht '" & szLookupViewName & "' wurde nicht gefunden !"
Messagebox szErrorMessage & MSG_INFORM_ADMIN, MB_ICONEXCLAMATION, "Fehler"
Exit Function
End If

'Get all documents containing szValue:
Set collFound = viewLookup.GetAllDocumentsByKey (szValue, True)

If collFound.Count = 0 Then
IsValueAmbiguous = False 'No document found - no ambiguous documents ...
Exit Function
End If

'Loop through all found documents:
Set docFound = collFound.GetFirstDocument

While Not (docFound Is Nothing)
If docFound.UniversalID <> docCurrent.UniversalID Then
IsValueAmbiguous = True 'A found doc but with another UNID - this is not allowed !
Exit Function
End If

Set docFound = collFound.GetNextDocument (docFound)
Wend

'If we come to this position there are no ambiguous values:
IsValueAmbiguous = False

Exit Function

ErrorRoutine:
Call ErrorHandler ("IsValueAmbiguous")
szErrorMessage = "Run-time error: " & Error$ & " (No. " & Cstr (Err) & " in line " & Cstr (Erl) & ")"
Exit Function
End Function
--- Ende Code ---

alexbeer:
Eine Frage habe ich noch.

Meine Abfrage habe ich jetzt in die Input Validation eingebaut. Ist nach dem Muster @if(...;@success;@failure("....")) aufgebaut
Funktioniert auch alles - aber wenn der THEN Teil der If-Abfrage zum Tragen kommt, dann kann ich das Dokument ja nicht speichern.
Kann man diesen Schutz irgendwie umgehen. Ich moechte das Dokuement ja trotz InputValidation Speichern koennen - auch wenn die Fehlermeldung kommt.  Also nur die Meldungen erhalten - keine weiteren Einschraenkungen.
Muesste soetwas dann mit in das Exiting Event?
Wenn ja, wie muesste ich mein @if(...;@success;@failure("....")) in LS formulieren.
In LS bin ich leider voellig hilflos...

Thomas Schulte:
Im Exiting Event nützt dir so was gar nichts. Wenn dann müsste das in den Query Save.
Und du könntest es zum Bleistift in der Input Validation so lösen. das der Failure Event nur dann getriggert wird wenn eine andere versteckte Variable nicht mit einem bestimmten Wert gefüllt ist.
Also so ungefähr.

@if(Bedingung;@if(VerstecktesFeld = "0";@do(@setfield(VerstecktesFeld;"1");@failure"DeinText"));@Success);@Success);

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln