2016-09-30 93 views
1

我是Lotus笔记中的初学者。我有一个关键字查找表单和一个编辑历史字段。每个更改都记录在编辑历史记录字段中。如下图所示,显示的编辑历史:莲花笔记:如何按降序对多值字段进行排序


日期:2016年2月10日 USER:(名) FROM:关键字:关键字值 TO:关键字:关键字值


日期:2016年5月29日 USER:(名) FROM:关键字:关键字值 TO:关键字:关键字值

的编辑历史追加的是降低之前的编辑,以便按升序显示。如何按降序对编辑历史进行排序?或者是否可以在先前的编辑历史记录上插入新的编辑历史记录以使其按降序排列?如果是的话,我该怎么做?预先感谢您的帮助。 :)

在我EditHistory多值字段,我有这样的代码:

@If(@IsDocBeingLoaded & @IsNewDoc; @Return(""); @True); 
@If([email protected]; @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 
+1

告诉我们的代码,您使用写的历史,那么我们就可以说明如何修改方向...没有代码,没有帮助! –

+0

在我的EditHistory多值字段中,我有这个代码 @If(@IsDocBeingLoaded&@IsNewDoc; @Return(“”); @True); (@Sort(EditHistory; [Descending])); @Trim(@Subset(@Sort(EditHistory; [Descending]); -100))) –

+0

声明中: Dim FieldValues()作为字符串 在我的表单中我有这些: 子EditHistorylist \t昏暗的会议作为新NotesSession \t昏暗的工作区作为新NotesUIWorkspace \t昏暗源作为NotesUIDocument \t昏暗fieldnum作为整数 \t昏暗的条目作为字符串 \t Dim histo As Variant \t \t集源= workspace.CurrentDocument \t \t 对于fieldnum = 0至UBOUND(FieldValues) –

回答

2

首先,历史记录中的每一行都是一个字符串,即使对这些行进行排序,结果也会按字典顺序排序,这意味着2016年2月10日仍将在05/29/2016之前,这将在05/29/2015之前。

排序此列表它完成似乎并不走的路。

是否可以在先前的编辑历史记录上插入新的编辑历史记录以使其降序?

当然是的,它是

我该怎么办呢?

这一切都取决于如何将新行添加到现场。使用@Formula它会相当简单,可能只是 历史记录:= newLine:历史记录

在LotusScript中,您可以使用history = document.getItemValue("history")获取现有行,这将生成一个数组。然后,您可以使用一些阵列福预先设置新的生产线,沿着

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可能会非常棘手,所以有耐心武装自己,并为您内置多米诺帮助设计师。

+0

我得到错误意外下降;预期:操作员; TO在线 对于i = Ubound(FieldValues)降至1 我该如何解决此问题?谢谢。 –

+0

[RTFM](https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.1/com.ibm.designer.domino.main.doc/LSAZ_CHAPTER_7_STATEMENTS_BUILTIN_FUNCTIONS_SUBS_DATA_TYPES_AND_DIRECTIVES.html)的确切语法;-) –

+0

好吧,感谢您:) –

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