Objective:End up with a list of the values for example in the StatusLog field, but with the newest value at the top.
Current problem:
Everything works OK, but the user has requested to have the field set so the latest value is at the top
Current idea(s) to resolve:
It’s a LotusScript Agent anyway, if we can do it in script ![]()
Easiest would be to use some exisitng functionality like:
Forall m In CurrentStatusLog
total = total + m
End Forall
doc.Total=Total
Except for somehow append a number to the start of each value in the total field, that represents it’s number in the list (Haven’t figured out how to do this yet!!)
If we could, then, I could use @Sort(NewFieldNameorValueorWhatever; [DESCENDING])
And I would think it would display the list in the preferred order, 10 (latest) at top, then 9 87654321 for example…then we’d have to clear the field, set it to that value, and remove all the numbering…
Anyone have a good way of doing this? Script or formula…
Here’s the whole of the current agent, that sets the ‘On Hold’ Status, for example:
Sub Initialize
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
'Call uidoc.Save
Dim Doc As NotesDocument
Set Doc = uidoc.Document
Dim tMainProjectPhase As Variant
tMainProjectPhase = doc.MainprojectPhase
Dim strMainProjectPhase As String
strMainProjectPhase = Cstr(tMainProjectPhase(0))
Dim user As String
user = session.CommonUserName
Dim NewStatus As String
NewStatus="On Hold"
Dim currentStatus As Variant
currentStatus = doc.ProjectStatus(0)
Dim OtherStatus As Variant
OtherStatus = doc.Status(0)
doc.tmpOtherStatus = OtherStatus
Dim OldCmpStatus As Variant
OldCmpStatus = doc.CmpStatus(0)
doc.tmpOldCmpStatus = OldCmpStatus
'Messagebox =
' new code
If uidoc.Editmode Then
Call uidoc.Reload
Call uidoc.FieldAppendText _
( "StatusLog", "," )
Call uidoc.FieldAppendText _
( "StatusLog", "The project status was changed from " + Cstr(currentStatus) + " to " + NewStatus + " by " + user + " on " +Cstr(Date) + " at " + Cstr(Time) + ".")
Call uidoc.FieldAppendText _
( "StatusLog", "," )
'Call uidoc.FieldSetText _
'( "LastChanged", "," )
Call uidoc.FieldSetText _
( "LastChanged", "The project status was last changed on " +Cstr(Date) + " at " + Cstr(Time) + ".")
'Call uidoc.FieldSetText _
'( "LastChanged", "," )
'uidoc.Refresh
Call uidoc.Save
doc.ProjectStatus=NewStatus
doc.CmpStatus=NewStatus
doc.SaveOptions=""
Call Doc.Save(True,True)
Call uidoc.Save
'Call uidoc.Close
Call uidoc.Refresh
Call Doc.Save(True,True)
Else
Dim CurrentStatusLog As Variant
CurrentStatusLog=doc.GetItemValue( "StatusLog" )
Dim CurrentLastChanged As Variant
CurrentLastChanged=doc.GetItemValue( "LastChanged" )
Forall m In CurrentStatusLog
total = total + m
End Forall
doc.Total=Total
Eval2=Evaluate(|@ReplaceSubstring(total; "." ; "." + @NewLine)|,doc )
Forall m In CurrentLastChanged
total1 = total1 + m
End Forall
doc.Total1=Total1
Eval3=Evaluate(|@ReplaceSubstring(total1; "." ; "." + @NewLine)|,doc )
Eval=Evaluate(|@Char(13)|)
'doc.StatusLog=Cstr(CurrentStatusLog(0)) +","
' cold code=Cstr(CurrentStatusLog(0)) for line below
doc.StatusLog=Cstr(Eval2(0)) + "The project status was changed from " + Cstr(currentStatus) + " to " + NewStatus + " by " + user + " on " +Cstr(Date) + " at " + Cstr(Time) + "."
'doc.StatusLog=Cstr(CurrentStatusLog(0)) +","
'Call uidoc.FieldSetText _
'( "LastChanged", "," )
doc.LastChanged= "The project status was last changed on " +Cstr(Date) + " at " + Cstr(Time) + "."
'Call uidoc.FieldSetText _
'( "LastChanged", "," )
'uidoc.Refresh
doc.ProjectStatus=NewStatus
doc.CmpStatus=NewStatus
doc.Status=NewStatus
doc.SaveOptions=""
Call Doc.Save(True,True)
Call workspace.EditDocument(False, doc)
'Call workspace.ViewRefresh
'Call doc.Open
End If
End Sub