Changing embedded view selection formula with LotusScript

Hello to all,

I set up a form that includes a table with four rows. In this table, which is displayed with tab-folders, an embedded view was added in the second row.

The view should show different documents depending on the content of a special field of the form. This field is set up in the first row of the table.

In detail, the first tab-folder lists the adress information of a company, the second folder should show the contacts to this company in a view.

The following code was added to the “initialize” section of the view:

Dim ws As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim uiDocument As NotesUIDocument

Dim view As NotesView

Dim formula As String

Set uidocument=ws.CurrentDocument

Set db = session.CurrentDatabase

Set view = db.GetView( “contact” )

Company=uiDocument.FieldGetText(“CompanyName”)

Formular =“contact”

formula = “SELECT ((Form = '”+Formular+“')) & (@Contains(ContactCompany; '”+Company+“'))”

view.SelectionFormula = formula

view.Refresh

The selection formula is computed in the right way and is saved to the view.

But there is no change in the entries showed by the view when I open different documents.

Where am I wrong ? I didn’t find any help in documentations - where do I have to look up ?

Thanks for your help in advance !

Ulli

Subject: changing embedded view selection formula with LotusScript

View selection formulas are hard to change that way, but since it seems like only the company name is changing, there might be a better way. Simply restrict the embedded view to a category, and categorize that view by company name. Then, your formula can work to determine which company shows.

Subject: changing embedded view selection formula with LotusScript

You can alter the view selection formula of a view through LotusScript, but it won’t work in a dynamic, real time way. The only way to see the changes in a reliable way, is to close and reopen the database. It’s also a very ‘expensive’ way of working in terms of performance.I advise you not to use this way of working to change view selections ‘on the fly’. It can be usefull to change views, that stay static for a while, after the change. For example: you can write an agent that change the selection formulas once a month, or during the night.

In your case I would advise to use single catagory views (as proposed by Ben), or to populate a folder on the fly.

Single category views will work much faster than the real-time calculating of documentcollections to populate a folder.