Show different background in views

HI,I have a view A in which after clicking of a button agent runs and after comparison with another view B if a document is not present that document is created. Up till now the functionality is created.

What needs to be achieved is written below.

If the document is created today in the view A, then background colour of that document should show yellow colour and if the document is not created today then it should be the normal white back ground.

The care that also needs to be taken is if today the document is created in back ground it should be yellow colour but for tomorrrow it should be white again.

How this can be achieved?

Pls reply asap.

Subject: Show different background in views…

You’ll have to put a flag on the document, and then clear all the flags each night with an agent.

Depending on the size of the db this may be no problem at all, but if it’s a large db with lots of local replicas you may want to reconsider as every replication each day will have to replicate over all the changed documents.

Subject: RE: Show different background in views…

Thanks for the reply. But can you pls be more details? That would be great.

Subject: RE: Show different background in views…

Put a field on the doc that needs the colour (is that docA). Call it something obvious - ‘docBCreatedToday’ for example. You say you have the code to create docB, so add an update to this field on docA in that code, putting a ‘Y’ in.

You then need a color column in the view when that field is ‘Y’ (examples in Designer help)

Then set up a scheduled agent, running every night at midnight (or a sensible time at least). The agent will run against all documents, with a document selection of field docBCreatedToday contains Y. Simple action, set field docBCreatedToday to “”.

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