View Selection Formula

Hi,

Can we set View Selection Formula dynamically?

Please help…

Subject: View Selection Formula

If you wish to change selection formula in views you can use next code

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim view As NotesView

Dim formula As String

formula = “SELECT (@Modified > [” & (Date - 7) & “])”

Set uiview = ws.CurrentView

Set view = uiview.View

view.SelectionFormula = formula

Subject: View Selection Formula

Depends on how you define “dynamically”. You can use LS code (e.g. in an agent) to modify selection formulas, but you will not want to do that in say a view action.

Subject: RE: View Selection Formula

Hi,

Thanks a lot. Can we set that in the Click action of a button?

Regards,

Sai.

Subject: RE: View Selection Formula

Yes, you can, but be aware of the implications.

The LS code would work straight in a button only, if the current user has designer rights. Usually, this will not be the case, so you would still have to put it in an agent that runs on behalf of someone who has and then call that agent from the button.

Next, changing the selection formula requires the view index to be rebuild, which might be slow and put some noticeable load on the server, if used frequently. Finally, if the view is currently open in the client, changes wont take effect, unless the back end view is refreshed and the front-end view is rebuild (from NotesUIWorkspace).

Also, if this is a shared view, changes affect all users of that database. Check carefully, if this solution is appropriate in your environment. In many - but surely not all - cases, full-text search will be a good alternative.

Subject: Sometimes its better to ask …

how do I achieve this business effect

rather than get focussed immediately into a single technical means

(no matter how promising)

You’ve told us you want to change a View selection formula

  • but not why

or how teh user interact

etc

etc

Presuming its to dynamically change what is appearing to the user

and there are several mechanisms to achieve an effect thats is VERY close to that

(without the downside to chaning teh SelectFormula itself)

For example if you can categorise a view in a suitable way - Showing a single category may be enough

Please give us some more background so we can guage the better approaches