我是Lotus笔记的初学者。我有一个关键字查找表单和一个编辑历史记录字段。每个更改都记录在编辑历史记录字段中。编辑历史记录显示如下:
日期:2016年10月2日 用户名) FROM:keyword ::关键字值 TO:keyword :: keyword values
日期:05/29/2016 用户名) FROM:keyword ::关键字值 TO:keyword :: keyword values
编辑历史记录中的追加位于上一编辑的下方,因此会按升序显示。如何按降序对编辑历史记录进行排序?或者是否可以在上一个编辑历史记录之上插入新的编辑历史记录以使其按降序排列?如果是,我该怎么做?提前感谢您的帮助。 :)
在我的EditHistory多值字段中,我有以下代码:
@If(@IsDocBeingLoaded & @IsNewDoc; @Return(""); @True);
@If(!@IsDocBeingSaved; @Return(@Sort(EditHistory;[Descending]));
@Trim(@Subset(@Sort(EditHistory;[Descending]) ; -100)))
在声明中:
Dim FieldValues() As String
在我的表格中,我有以下内容:
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
记录事件:
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
答案 0 :(得分:2)
首先,历史记录中的每一行都是一个字符串,即使您对这些行进行排序,结果也会按字典顺序排序,这意味着02/10/2016仍将在05/29/2016之前,将在05/29/2015之前。
在完成之后对此列表进行排序似乎不太可能。
是否可以在上一个编辑历史记录之上插入新的编辑记录以使其按降序排列?
是的,当然是
我该怎么做?
这一切都取决于新行如何添加到字段中。使用@Formula它可能相当简单,也许只是 history:= newLine:history
在LotusScript中,您可以使用history = document.getItemValue("history")
获取现有行,这将产生一个数组。然后你可以使用一些array-fu来添加新行,这是
redim preserve history(ubound(history)+1)
for i = ubound(history) down to 1
history(i) = history(i-1)
next
history(0) = newLine
call document.replaceItemValue("history", history)
现在,在LotusScript中处理动态数组可能会非常棘手,因此请耐心等待,并检查Domino Designer中内置的帮助。
答案 1 :(得分:0)
试试这个:
Dim newRow(0) As String
newRow(0) = "new history line"
If document.History(0) = "" Then
document.History=newRow
Else
document.History = Arrayappend(newRow, document.history)
End If