Lotus notes LotusNotes:如何按降序对多值字段排序
我是Lotus notes的初学者。我有一个关键字查找表和一个编辑历史字段。每次更改都记录在“编辑历史记录”字段中。编辑历史记录显示如下所示:Lotus notes LotusNotes:如何按降序对多值字段排序,lotus-notes,lotusscript,lotus,lotus-formula,Lotus Notes,Lotusscript,Lotus,Lotus Formula,我是Lotus notes的初学者。我有一个关键字查找表和一个编辑历史字段。每次更改都记录在“编辑历史记录”字段中。编辑历史记录显示如下所示: 日期:2016年10月2日 用户:(姓名) 发件人:关键字::关键字值 到:关键字::关键字值 日期:2016年5月29日 用户:(姓名) 发件人:关键字::关键字值 到:关键字::关键字值 编辑历史记录中的追加位于上一次编辑的下方,因此将按升序显示。如何按降序排列编辑历史记录?或者,是否可以在以前的编辑历史记录之上插入新的编辑历史记录,使其按降序排
日期:2016年10月2日 用户:(姓名) 发件人:关键字::关键字值 到:关键字::关键字值
日期:2016年5月29日 用户:(姓名) 发件人:关键字::关键字值 到:关键字::关键字值 编辑历史记录中的追加位于上一次编辑的下方,因此将按升序显示。如何按降序排列编辑历史记录?或者,是否可以在以前的编辑历史记录之上插入新的编辑历史记录,使其按降序排列?如果是,我怎么做?提前感谢您的帮助。:)
在我的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
首先,历史记录中的每一行都是一个字符串,即使您对这些行进行排序,结果也将按字典顺序排序,这意味着2016年10月2日仍将在2016年5月29日之前,即2015年5月29日之前 在列表完成后对其进行排序似乎不是一个好办法 是否可以在以前的编辑历史记录之上插入新的编辑历史记录,使其按降序排列 是的,当然是 我该怎么做 这完全取决于新行如何添加到字段中。有了@Formula,它将相当简单,也许只是 历史记录:=换行符:历史记录 在LotusScript中,可以使用
history=document.getItemValue(“history”)
获取现有行,这将生成一个数组。然后,您可以使用一些数组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中内置的帮助。尝试以下方法:
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
向我们展示你用来写历史的代码,然后我们可以展示如何修改方向。。。没有代码,就没有帮助!在我的EditHistory多值字段中,我有以下代码@If(@IsDocBeingLoaded&@IsNewDoc;@Return(“”;@True))@如果在声明中(!@IsDocBeingSaved;@Return(@Sort(EditHistory;[Descending]));@Trim(@Subset(@Sort(EditHistory;[Descending]);-100)):Dim FieldValues()作为我表单中的字符串,我有以下内容: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 History As Variant Set source=workspace.CurrentDocument For fieldnum=0 To Ubound(FieldValue)If FieldValue(fieldnum,1)source.fieldgettext(FieldValues(fieldnum,0))然后entry=Chr(10)+DATE:“+DATE$+Chr(10)+”USER:“+session.CommonUserName+Chr(10)+”FROM:“+FieldValues(fieldnum,0)+”::“+FieldValues(fieldnum,0)+Chr(10)+Chr(95)+Chr(95)调用source.FieldAppendText(“EditHistory”,Chr(10)+entry)End If Next End SubSub Querysave(source作为Notesuidocument,Continue作为Variant)If note.IsNewDoc然后调用EditHistorylist End If End SubI获得意外错误;预期:运营商;要将i=Ubound(FieldValues)的行降到1,我可以做些什么来解决此问题?非常感谢。精确语法;-)
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