« Return to the blog entry
@Martin: The problem of your solution is that you cannot be sure, that the view is rebuildt on every server and on the local replicas.
@Jake
I have a general solution which works for selection formulas as well as for view columns.
In the selection formulas I start with
vToday := @Date(2005; 9; 9);
REM {END vToday};
end use the variable vToday instead of @Today.
My nightly agents is:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim org As String, changed
Dim flag
Set db = session.CurrentDatabase
Forall view In db.Views
flag = False
org = view.SelectionFormula
changed = SetToday(org)
If Not Isnull(changed) Then
view.SelectionFormula = changed
flag = True
End If
If Isarray(view.Columns) Then
Forall column In view.Columns
org = column.Formula
column.Formula = changed
End Forall
' refresh view
If flag Then view.Refresh
End Sub
Function SetToday(Byval pStr)
Dim pos1 As Integer
Dim pos2 As Integer
pos1 = Instr(pStr, "vToday :=")
pos2 = Instr(pStr, |REM {END vToday};|)
If pos1 = 1 And pos2 > 0 Then
SetToday = |vToday := @Date(| & Format(Today, "yyyy\; mm\; dd") & |);
| &Mid(pStr, pos2 - 1)
Else
SetToday = Null
End Function
@Martin: The problem of your solution is that you cannot be sure, that the view is rebuildt on every server and on the local replicas.
@Jake
I have a general solution which works for selection formulas as well as for view columns.
In the selection formulas I start with
vToday := @Date(2005; 9; 9);
REM {END vToday};
end use the variable vToday instead of @Today.
My nightly agents is:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim org As String, changed
Dim flag
Set db = session.CurrentDatabase
Forall view In db.Views
flag = False
org = view.SelectionFormula
changed = SetToday(org)
If Not Isnull(changed) Then
view.SelectionFormula = changed
flag = True
End If
If Isarray(view.Columns) Then
Forall column In view.Columns
org = column.Formula
changed = SetToday(org)
If Not Isnull(changed) Then
column.Formula = changed
flag = True
End If
End Forall
End If
' refresh view
If flag Then view.Refresh
End Forall
End Sub
Function SetToday(Byval pStr)
Dim pos1 As Integer
Dim pos2 As Integer
pos1 = Instr(pStr, "vToday :=")
pos2 = Instr(pStr, |REM {END vToday};|)
If pos1 = 1 And pos2 > 0 Then
SetToday = |vToday := @Date(| & Format(Today, "yyyy\; mm\; dd") & |);
| &Mid(pStr, pos2 - 1)
Else
SetToday = Null
End If
End Function