How to specify agent / formula to retrieve documen

2019-09-07 06:19发布

The form contains "searchInputField" and simple button for it. Below the button, there is a view.

How can i specify SELECT formula in VIEW according to searchInputCriteria? I want to refresh VIEW when button is clicked after setting "searchInputField". It should be like simple custom search.

On button click i have done:

@SetEnvironment("criteria", "searchInputField");
@Command([RunAgent];"searchAgent");
@Command([ViewRefreshFields]);

My agent does:

SELECT @Like(propertyA, @Environment("criteria"));

But it doesn't do anything. I'm new to Lotus Notes. Please, give me some guidelines

Thanks in advance

1条回答
再贱就再见
2楼-- · 2019-09-07 06:56

You could use this script inside your button but it won't work in a dynamic, real-time way:

Dim db As NotesDatabase
Dim session As New NotesSession
Dim uiw As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim formula As String
Dim doc As NotesDocument
Dim view As NotesView       
Set db=session.CurrentDatabase
Set uidoc=uiw.CurrentDocument
Set doc=uidoc.Document
Set view=db.GetView("MyEmbeddView")     
formula$={SELECT  @Like(criteria;  "} & doc.searchInputField(0) & {")}
view.SelectionFormula=formula

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 useful to change views that stay static for a while after the change. For example you could write an agent that changes the selection formulas on a periodic basis (e.g., monthly or daily at a non-peak time or during a maintenance window).

In your case I advise using single category views or to populate a folder on the fly. Single category views will work much faster than dynamically calculating the DocumentCollection used to populate a folder.

查看更多
登录 后发表回答