Subject: Show different background in views…
I have an alternative, which is a bit more complex, but may offer performance improvements if you have other views that display information based on today’s date.
For our internal helpdesk I have a column that evaluates to a colour to highlight the document based upon how close the due date is to today. Of course using @Today in a view selection or column formula kills performance. So the column formula uses:
today:=[21/12/2007];
warningRed:=255:0:0:0:0:0;
@If(today=DueDate; warningRed; “”)
“today:=” needs to be the first line of the column formula/selection formula, and case sensitivity needs to be correct (you’ll see when we get to the agent). The agent needs to allow restricted operations and needs to run on behalf of an id that has access to run adminP processes.
The sophisticated part is manipulating the today date each day. This is done with a scheduled agent to loop through relevant views in the database (it could be easily modified to run through all views in the database), replace the date in the “today” variable with the today’s date for both selection formulae and column formulae, and then sign the database with the server id. This is important, because otherwise regardless of who the agent runs as, it seems to leave the design element signed with ‘No signature’.
The code for the agent is:
Dim s As New NotesSession
Dim thisdb As NotesDatabase
Dim updateView As NotesView
Dim todaydate As String, formula As String
Dim views List As String
Dim instrPos As Long
%REM
Use this format
views(VIEWNAME) = viewAlias
%END REM
views("(PONotUploaded)") = "PONotUploaded"
views("dlStepLookup") = "dlStepLookup"
Set thisdb = s.CurrentDatabase
todayDate = Format(Today(), "dd/mm/yyyy")
Dim instrPos As Long
Forall viewName In views 'Loop through views
Set updateView = thisdb.GetView(viewName)
formula = updateView.SelectionFormula
instrPos = Instr(formula, "today:=")
If instrPos > 0 Then
Mid$ (formula, InstrPos + 8, 10) = todayDate
updateView.SelectionFormula = formula
End If
Forall vc In updateView.Columns
If vc.IsFormula Then
formula = vc.Formula
instrPos = Instr(formula, "today:=")
If instrPos > 0 Then
Mid$ (formula, InstrPos + 8, 10) = todayDate
vc.Formula = formula
End If
End If
End Forall
End Forall
'Now we need to sign the database - otherwise the design element is signed with No Signature!
Set adminp = s.CreateAdministrationProcess(thisdb.Server)
Print thisdb.Server
Print thisdb.FilePath
Call adminp.SignDatabaseWithServerID(thisdb.Server, thisdb.FilePath, False)
Hope this is of use. Any problems, please email me at pwithers@intec.co.uk