Guten Morgen,
ich habe grade folgendes Problem:
ich habe in einer Ansicht ein "Move Up" bzw. Move Down" button eingebaut, der mit einem Action verbunden ist. Es soll dadurch eine Zeile in der Ansicht nach oben bzw. nach untern verschieben werden. Leider klappt es nicht wie erwartet. Kann jemanden mir Vielleicht sagen, was ich Falsche gemacht habe.... :-:
Ich bekomme immer die Meldung "You can't move the document any higher.", obwohl es ein höher Dokument gibt.
Der Action für die "Move up" button ist wie folgt:
Sub Click(Source As Button)
Dim ses As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim uiView As NotesUIView
Dim view As NotesView
Dim doc As NotesDocument
Dim prevDoc As NotesDocument
Set db = ses.CurrentDatabase
Set uiview = ws.CurrentView
Set view = uiview.View
Set dc = db.UnprocessedDocuments
On Error Resume Next
If (dc.Count <> 1) Then
Messagebox "You have to select a document to move.", 16, "Error"
Exit Sub
End If
Set doc = dc.GetFirstDocument()
Set prevDoc = view.GetPrevDocument( doc)
Do Until prevDoc.Form( 0) <> "Document"
Set prevDoc = view.GetPrevDocument( prevDoc)
If prevDoc Is Nothing Then Exit Do
Loop
If ( prevDoc Is Nothing) Then
Messagebox "You can't move the document any higher.", 48, "Error"
Exit Sub
End If
Call SwapDocuments( prevDoc, doc)
ws.ViewRefresh
uiview.SelectDocument( doc)
End Sub
Die SwapDocuments wie folgt :
Sub SwapDocuments( sourceDoc As NotesDocument, destDoc As NotesDocument)
Dim ssort As Integer
Dim dsort As Integer
ssort = sourceDoc.Nb_SortOrder(0)
dsort = destDoc.Nb_SortOrder(0)
If ssort = dsort Then
ssort = dsort + 1
End If
sourceDoc.Nb_SortOrder = dsort
destDoc.Nb_SortOrder = ssort
Call sourceDoc.Save(True,False)
Call destDoc.Save(True,False)
End Sub
Ich hoffe mir kann jemand helfen ... :-\
Vielen Dank im Voraus :)
Gruß
Salih
Hallo,
Ich verwende dazu das Script(move up):
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim doca As NotesDocument
Dim docb As NotesDocument
Dim myview As NotesView
Dim myuiview As NotesUIView
Dim ws As New NotesUIWorkspace
Dim posa As Variant
Dim posb As Variant
Set myuiview = ws.currentview
Dim viewname As String
viewname = myuiview.ViewName
Set db = s.CurrentDatabase
Set myview = db.GetView(viewname)
Set doc = myview.GetFirstDocument
Set dc = db.UnprocessedDocuments
If dc.Count = 1 Then
Set doca = dc.GetFirstDocument()
If Not (doca.universalid = doc.UniversalID) Then
Set docb = myview.getprevdocument(doca)
posa = doca.position
posb = docb.position
If (Val(posa(0)) > 0) And (Val(posa(0)) > Val(posb(0))) Then
doca.position = posb
docb.position = posa
Call doca.Save( False, True )
Call docb.Save( False, True )
Call ws.ViewRefresh
Call myuiview.SelectDocument(doca)
End If
Else
Msgbox "Das Dokument ist schon ganz oben."
End If
Else
Msgbox "Bitte nur ein Dokument auswählen."
End If
Wobei die View nach dem Feld Position sortiert wird.
Move down muss dann natürlich angepasst werde.
robert