如何在 Lotus domino 中创建自动递增字段?
我在 Lotus domino 中有一个应用程序,其中包含一个字段
UNIDID-number(compulated)...
我希望每次创建新条目时,该字段都会增加 1 并且应存储新值在新记录文档中..
我有一个 @dbcolumn 公式,它将获取 UNIDID 字段中的最后一个条目
- mFind:=@DbColumn("" : "NoCache" ; @DbName ; "lkpEmpMasterbyOnlyUnidCode";1);
如何递增 mFind 并以“UNIDXXXX”的形式提交?
I have an application in lotus domino with a field
UNIDID-number(computed)...
I want that every time a new entry is created, this field to increment by 1 and the new value should be stored in new record document..
I have a @dbcolumn formula which will get me the last entry in the UNIDID field-
mFind:=@DbColumn("" : "NoCache" ; @DbName ; "lkpEmpMasterbyOnlyUnidCode";1);
How do I increment mFind and submit it in form of 'UNIDXXXX'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
采用文档锁定来确保顺序文档编号解决方案中的编号唯一性
Employ document locking to assure number uniqueness in sequential document numbering solution
要回答您的具体问题:
lastEntry := @Subset(mFind;-1);
“UNID”+最后一个条目;
但您应该考虑以下几点:
“UNID”是一个在 Notes 和 Domino 中具有非常特定含义的术语。它是指自动分配给每个数据库中每个文档的通用 ID。如果您在应用程序中将此术语用于其他目的,那么有一天,当其他 Notes 专家必须查看您的应用程序时,您可能会造成混乱。
分配顺序 ID 的最佳方法是让服务器为您执行此操作。即,使用空字段保存文档,并创建一个在新文档和编辑文档上运行的代理,检查空字段,并在必要时分配下一个可用 ID。由于一次只能在数据库中运行一个代理,并且一次只能处理一个文档,这保证了您不可能同时使用相同的唯一 ID 保存两个文档。这样做的缺点是,在代理有机会运行之前,您无法向用户显示顺序 id。
To answer your specific question:
lastEntry := @Subset(mFind;-1);
"UNID" + lastEntry;
But here are a couple of things you should think about:
"UNID" is a term that has a very specific meaning in Notes and Domino. It refers to the Universal ID that is automatically assigned to every document in every database. If you use this term in your application for another purpose, you are likely to cause confusion someday when some other Notes expert has to look at your application.
The best way to assign a sequential id is to let the server do it for you. I.e., save the document with an empty field, and create an agent that runs on new and edited documents, checks for the empty field, and assigns the next available id if necessary. Since only one agent can run in the database at a time, and it works on only one document at a time, this guarantees that you can't possibly have two documents that are saved simultaneously with the same unique id. The downside of this is that you can't show the user the sequential id before the agent gets a chance to run.
阅读Notes/Domino 中顺序编号的综合处理 由 IBM 员工 Andre Guirard 编写。他认为使用 @DBColumn 进行顺序编号存在重大性能风险,并提供了替代方法的算法和代码。
我推荐使用清单 2 中的代码在“按需生成编号”标题下的方法。文档锁定是多余的 - 仅检测编号文档自读取以来是否已被修改并做出相应反应就足够了。
Read the comprehensive treatment of sequential numbering in Notes/Domino written by IBMer Andre Guirard. He considers the use of @DBColumn for sequential numbering a significant performance risk and provides algorithms and code for alternative approaches.
I recommend the approach under the heading "Number Generation On Demand" using the code in Listing 2. Document locking is overkill- merely detecting whether the numbering document has been modified since it was read and reacting accordingly is sufficient.
该公式来自我的技术注释数据库,使用表单上的组合时计算字段生成一个连续递增的数字,以便用户可以看到该数字,但仅在保存文档时才固定。
T_List:=@DbColumn("" : "NoCache"; ""; "RefNumView"; 1);
@If(@IsNewDoc & @Elements(T_List)=0;1;@IsNewDoc & !@IsError(T_List);@Subset(T_List;1) + 1;RefNumber)
您需要一个按降序排序的视图第一列与存储您的号码的字段,如果视图没有记录,上面的代码从 1 开始编号
数据库是在 Notes 4.5 中开发的,但我现在仍在使用 8.5 Notes 客户端&设计师并且从未需要更改公式,事实上,多年来它在所有后来的版本中被重复使用了很多次。如果文档是在多个服务器上创建的,则它将不起作用,因为计划代理是获得真正唯一的顺序编号的唯一方法。
This formula is from my technical notes database, generates a sequentially increasing number using a computed when composed field on the form so user can see the number but it is only fixed when you save the document.
T_List:=@DbColumn("" : "NoCache"; ""; "RefNumView"; 1);
@If(@IsNewDoc & @Elements(T_List)=0;1;@IsNewDoc & !@IsError(T_List);@Subset(T_List;1) + 1;RefNumber)
You need a view first column sorted in descending order with the field that stores your number, if the view has no records the code above starts numbering at 1
The database was developed in Notes 4.5 but I'm still using it now with 8.5 notes client & designer and have never needed to change the formula, indeed its been reused many times over the years in all the later versions. It won't work if documents are created on multiple servers, for that the scheduled agent is the only way to get a truly unique sequential numbering.