更新计算字段而不验证
我有一个带有字段 ItemNumber
的表单,该表单具有确保输入值的验证论坛。
在lotusscript中,我使用该表单创建一个新文档,然后根据不同计算字段ItemProductFamilyType
(根据另一个文档的字段计算)的值,我可能想要填充ItemNumber.
我遇到的问题是,如果我查看 ItemProductFamilyType
的值,它是空白的,因为它尚未计算。只有在更新字段后它才会有一个值,然后刷新/重新计算文档。
我尝试为此使用ComputeWithForm(其中raiseError参数为1或0),但是由于其他字段上的验证公式,它不允许我这样做。
那么,如何在不检查/错误验证公式的情况下让计算字段更新其值?
I have a form with a field ItemNumber
that has a validation forumla that ensures a value is entered.
In lotusscript i create a new document with that form, then depending on the value of a different computed field ItemProductFamilyType
(computed based on a field of another doc) i might want to populate ItemNumber
.
The issue i have is that if i look at the value of ItemProductFamilyType
it's blank, because it's not yet been computed. It'll only have a value once a field is updated, then it's the document refreshed/re-computed.
I'm trying to use ComputeWithForm
for this (with the raiseError
parameter being a 1 or 0), however because of validation formulas on other fields it's not letting me.
So, how can i get computed fields to update their value without checking/erroring on validation formulas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试添加验证控制字段。因此,添加一个名为“runValidation”的字段。它是为显示而计算的,因为它仅是 UI 表单事件处理所需要的。它的公式很简单
@ThisValue 或 runValidation
在 QueryRecalc 事件中或每当您想要设置 ItemProductFamilyType 的值时将其设置为“1”。
同样的想法也适用于 ItemProductFamilyType 的翻译公式。
在 ItemNumber 的验证公式中,包含“runValidation”字段来管理该字段何时应验证。
您现在应该能够安全地调用
Source.Refresh
方法,而不会无意中触发验证规则,直到数据准备就绪。Try adding a validation control field. So, add a field called "runValidation". It's computed for display, as it's only required for UI form events handling. It's formula is straight forward
@ThisValue or runValidation
In the QueryRecalc event or whenever you want to set the value for ItemProductFamilyType set it to "1".
The same idea works in the translation formula of ItemProductFamilyType
In the validation formula for ItemNumber include the "runValidation" field to manage when the field should validate.
You should now be able safely call a
Source.Refresh
method without inadvertently triggering validation rules until the data is ready.我不确定是否有特定于 Lotus Notes 的解决方法,但在任何系统中都适用的一个技巧是在验证公式中进行另一项测试。不要只是说
@If(FieldName != ""; @Failure; @Success)
,而是添加另一个您可以控制的条件,例如@If(DoValidation = "Yes" & FieldName ! =“”;@失败;@成功)
。然后您可以通过控制 DoValidation 项的值来控制验证。我经常将 @IsDocBeingSaved 添加到条件中,以便仅在保存文档时才会触发验证:
I'm not sure if there's a Lotus Notes-specific workaround for this, but one trick that would work in any system is to have another test in your validation formulas. Instead of saying just
@If(FieldName != ""; @Failure; @Success)
, add another condition that you can control like@If(DoValidation = "Yes" & FieldName != ""; @Failure; @Success)
. Then you can control validation by controlling the value of the DoValidation item.I often add @IsDocBeingSaved to the condition so that validation only fires when you are saving the document:
考虑到
ComputeWithForm
方法可能不可靠,另一个想法是:为什么不使用 LotusScript 检查其他文档中的值?事实上,您可以从 QueryRecalc 事件调用相同的代码并更新ItemProductFamilyType
项,从而无需重复代码。Another thought, given the potential that the
ComputeWithForm
method is unreliable: Why not check the value in the other document using LotusScript? In fact, you could call that same code from the QueryRecalc event and update theItemProductFamilyType
item, sparing you the need to duplicate code.