如何使用 LotusScript 函数作为文档选择例程
我们可以使用 LotusScript 函数作为视图选择公式中的文档选择例程吗?
这是我的莲花函数,它确定选择标准
Function MyFilter(doc As NotesDocument) as boolean
'非常复杂的过滤函数 '........
结束函数
这是我想要将 Lotus 函数合并到
中的视图选择公式 选择(表格=“表格1”)
我们可以在选择公式中使用上面的 LotusScript 函数吗?
<代码> SELECT (Form = "Form1" & MyFilter(sourceDoc))
我们能否避免在视图选择中使用公式语言并在运行时填充视图 通过遍历数据库中的每个文档并根据需要将文档添加到视图中?
有没有办法编写“用户定义公式”(公式语言)?
我们可以编写一个 C API 来解决此类问题吗?
Can we use a lotusscript function as a document selection routine inside view selection formula ?
Here is my lotus function which determines the selection criteria
Function MyFilter(doc As NotesDocument) as boolean
'very complex filtering function
'........
End Function
and here is the view selection formula that i want to incorporate the lotus function inside
SELECT (Form = "Form1")
can we use the above lotusscript function inside the selection formula in any way?
SELECT (Form = "Form1" & MyFilter(sourceDoc))can we avoid the formula language in the view selection and populate the view at run time
by traversing each document in the database and adding the document to the view as required?Is there a way to write a "user defined formula" (formula language)?
Can we write a C API to address such problems?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,视图选择公式不能包含 LotusScript
不是视图,但您可以看到其中的内容。我过去曾使用文件夹来完成此操作。视图包含一组与视图选择公式匹配的文档。另一方面,文件夹可以包含由用户或代码放置在其中的文档集合。在 Lotusscript 世界中,您可以使用 NotesView 类以与视图相同的方式访问文件夹。然后,您可以调用文档的 PutInFolder 方法或文档集合的 PutAllInFolder 方法将文档添加到该文件夹。
没有。不过,您可以通过 SelectionFormula 属性以编程方式指定视图使用的公式。但该属性需要一个用公式语言编写的字符串。
我对 C API 不太熟悉,但我敢打赌,您只能执行与 #3 相同的操作 - 指定用作选择公式的公式。它不会帮助您选择基于 LotusScript 代码的文档。
我之前在几个项目中已经走过这条路,我发现的最佳解决方案就是我在答案#2 中建议的解决方案。也就是说,您可以通过编程方式清除并填充文件夹,然后将用户带到该文件夹,作为代码中的最后一步。使用该方法,您可以自由地使用 LotusScript 来过滤文档并构建“查询结果”视图。
您可以使用的另一种不太理想但实用的方法是用特殊值标记所有文档中的一个项目,然后过滤视图以仅显示项目等于该特殊值的文档。例如,您可以在 LotusScript 中运行搜索,以使用 db.Search 方法构建文档集合。然后使用 documentcollection.StampAll 方法将“SHOWME”项设置为“YES”。然后您的视图只需设置为仅显示 SHOWME =“YES”的文档。当然,作为此代码的第一步,您需要从数据库中的所有文档中删除该 SHOWME 项,因此每次都从头开始。您拥有的文档越多,此方法就会变得越来越慢,但如果您只有几百个文档,那么它就可以正常工作。
希望这有帮助!
No, view selection formulas cannot contain LotusScript
Not with a view, but you're onto something there. I've done that in the past using folders. Views contain a set of documents that match a view selection formula. Folders, on the other hand, can contain a collection of documents placed there by a user or by code. In the Lotusscript world, you access a folder the same way as a view, using the NotesView class. Then you can call the document's PutInFolder method or a documentcollection's PutAllInFolder method to add documents to that folder.
No. You can programmatically specify the formula used by views, though, via the SelectionFormula property. But that property expects a string written in formula language.
I'm not very familiar with the C API, but my bet is you can only do the same as #3 - specify the formula used as the selection formula. It won't help you select documents based on LotusScript code.
I've been down this road before in a few projects, and the best solution I found was what I suggest in answer #2. That is to say you can clear and then populate a folder programmatically, and then take the user to that folder as the final step in your code. Using that method you are free to use LotusScript to filter the documents and build your "query results" view.
Another less ideal, but functional method you can use is to stamp one item within all the documents with a special value, then filter a view to show only documents with items equal to that special value. For example, you can run a search in LotusScript to build a documentcollection using the db.Search method. Then use the documentcollection.StampAll method to set the "SHOWME" item to "YES". Then your view will just have to be set to show only documents where SHOWME = "YES". Of course, you'll need to remove that SHOWME item from all documents in the database as a first step in this code, so you're starting with a clean slate each time. This method would get increasingly slow the more documents you have, but if you only have a few hundred docs it would work fine.
Hope this helps!
遗憾的是,您无法在视图选择公式中使用 Lotuscript。但是,我们过去解决此问题的一种方法是在表单上的 QuerySave(或 WebQuerySave)事件中调用复杂的公式,并将所有文档上的隐藏字段设置为“是”或“否”。然后,只需使用该隐藏字段在您看来选择公式:
Unfortunately, you cannot use Lotuscript in view selection formulas. However, one way we have addressed this in the past is to have your complex formula called in a QuerySave (or WebQuerySave) event on a form, and set a hidden field on all documents to Yes or No. Then, simply use that hidden field in your view selection formula: