I am a beginner in Lotus notes. I have a keyword look-up form and an edit history field. Every change is recorded in the edit history field. The edit history is displayed as shown below:
DATE: 02/10/2016 USER: (name) FROM: keyword::keyword values TO: keyword::keyword values
DATE: 05/29/2016 USER: (name) FROM: keyword::keyword values TO: keyword::keyword values
The append in the edit history is below the previous edit so it is displayed in ascending order. How can I sort the edit history in descending order? Or is it possible to insert new edit history above the previous edit history to make it in descending order? If yes, how can I do this? Thank you in advance for all your help. :)
In my EditHistory multivalued field, I have this code:
@If(@IsDocBeingLoaded & @IsNewDoc; @Return(""); @True);
@If(!@IsDocBeingSaved; @Return(@Sort(EditHistory;[Descending]));
@Trim(@Subset(@Sort(EditHistory;[Descending]) ; -100)))
In declarations:
Dim FieldValues() As String
In my form I have these:
Sub EditHistorylist
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim source As NotesUIDocument
Dim fieldnum As Integer
Dim entry As String
Dim histo As Variant
Set source = workspace.CurrentDocument
For fieldnum = 0 To Ubound(FieldValues)
If FieldValues(fieldnum,1) <>source.fieldgettext(FieldValues(fieldnum,0)) Then
entry = Chr(10) + "DATE:" + Date$+Chr(10)+ "USER:" + session.CommonUserName +_
Chr(10)+ "FROM:" + FieldValues(fieldnum,0) + "::" + FieldValues(fieldnum,1)+_
Chr(10)+ "TO:" + FieldValues(fieldnum,0) + "::" + source.fieldgettext(FieldValues(fieldnum,0)) +_
Chr(10) + Chr(95) + Chr(95) + Chr(95)
Call source.FieldAppendText("EditHistory",Chr(10)+entry)
End If
Next
End Sub
Document events:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
If Not Source.IsNewDoc Then
Call EditHistorylist
End If
End Sub
Sub Postmodechange(Source As Notesuidocument)
'build array of current values
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim form As NotesForm
Dim fieldnum As Integer
Dim counter As Integer
Set db = session.CurrentDatabase
Set doc = Source.Document
Set form = db.GetForm(doc.Form(0))
fieldnum = Ubound(form.fields)
Redim FieldValues(fieldnum,1)
counter = 0
Forall field In form.fields
FieldValues(counter,0) = field
FieldValues(counter,1) = source.fieldgettext(field)
counter = counter + 1
End Forall
End Sub