Possible solution for @Today in views and columns?

I had an idea and I’d like to know if you think it is good or if it has flaws.

I have the age old problem where I’d like to display a view icon in a column if a date is more than two months in the past. If I use @Today, the view refresh icon is constantly displayed, and the server is constantly thinking that it needs to update the view.

Would it be a good idea to create a profile document with today’s date, and then reference it in the column formula? I could run an agent each day after midnight to update the value. Hopefully, the profile document would offer decent performance and the view would not be slow to display or cause much of a hit for the server.

My application is for the Notes client only.

TIA.

Subject: Possible solution for @Today in views and columns?

You can’t reference Profile documents (or environment variables) from View Column or selection formulas.

Your best bet is to have a nightly agent that sets a flag on documents, to indicate if it is “recent” or not.

A very simple formula agent would do.

Select Form = “YourFormGoesHere”;

days := 60;

cutoffDate := @Adjust(@Today; 0; 0; -days; 0; 0; 0);

flagRecent := @If(@Modified > cutoffDate; “1”; “0”);

@If(Within60Days = flagRecent; @Return; “”);

Field Within60Days := flagRecent;

The above agent only modifies the documents where the flag field value (Within60Days) has actually changed.

Set the agent to trigger on All documents in database.

Subject: Thanks, Morten.

Subject: RE: Possible solution for @Today in views and columns?

Alternately, now that you can write column formulas using LotusScript, you could run a nightly agent to update the view design to compare the date in a field to a hardcoded date that you change daily. Don’t forget to view.refresh so that the first user in the morning doesn’t have to wait for the view to rebuild.

By avoiding unnecessary document modifications, your application will perform better and the chance of replication conflicts will be less (in case a user made a change in a local replica and didn’t replicate before they shut down their computer for the night).

Users with local replicas who don’t replicate regularly with the server, will not see the latest “late” icons, but this is also true of Morten’s suggestion.

Subject: Thanks, Andre. Interesting, but one disadvantage …

I like that idea and I appreciate the reminder about the ability to change column formulas via lotusscript.

In my situation, I’d like the view icons to display in almost all of the many views. This will give users consistency - they will see them often and recognize them, and will not be confused if some views have the view icons while others don’t. In other words, if one view indicates a late request with an icon, I want them all to have it to avoid confusion.

That would mean that I’d have to update many views each night, and the database could be a pain for first users of each view each day.

At this point I am leaning towards a nightly agent to update documents when necessary. I will not update a document if the flag does not need to be changed. We think replication is rarely used by users, so I don’t think I will be introducing a substantial conflict potential.

Thanks again for the responses.

Subject: RE: Thanks, Andre. Interesting, but one disadvantage …

You can avoid the long wait for the first user by having the scheduled agent regenerate the view index with a NotesView.Refresh – as I said before.

Subject: Oh! Missed that. Thanks, again! :-).

.