更新计算字段而不验证

发布于 2024-12-08 11:14:58 字数 433 浏览 5 评论 0原文

我有一个带有字段 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你如我软肋 2024-12-15 11:14:58

尝试添加验证控制字段。因此,添加一个名为“runValidation”的字段。它是为显示而计算的,因为它仅是 UI 表单事件处理所需要的。它的公式很简单

@ThisValue 或 runValidation

在 QueryRecalc 事件中或每当您想要设置 ItemProductFamilyType 的值时将其设置为“1”。

Sub Queryrecalc(Source As Notesuidocument, Continue As Variant)
    On Error Goto errHandle
    Dim doc As notesDocument
    Set doc = source.Document
    ' go populate your fields like ItemProductFamilyType
    doc.runValidation = "1"
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " : " + Str(Err) + " - " + Error(Err) + ", at line " + Str(Erl)    
    Exit Sub 
End Sub

同样的想法也适用于 ItemProductFamilyType 的翻译公式。

Field runValidation := "1";
@thisValue;

在 ItemNumber 的验证公式中,包含“runValidation”字段来管理该字段何时应验证。

@if(runValidation="1";@if(@trim(@ThisValue)="";@Failure("Enter value");@Success);@Success)

您现在应该能够安全地调用 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".

Sub Queryrecalc(Source As Notesuidocument, Continue As Variant)
    On Error Goto errHandle
    Dim doc As notesDocument
    Set doc = source.Document
    ' go populate your fields like ItemProductFamilyType
    doc.runValidation = "1"
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " : " + Str(Err) + " - " + Error(Err) + ", at line " + Str(Erl)    
    Exit Sub 
End Sub

The same idea works in the translation formula of ItemProductFamilyType

Field runValidation := "1";
@thisValue;

In the validation formula for ItemNumber include the "runValidation" field to manage when the field should validate.

@if(runValidation="1";@if(@trim(@ThisValue)="";@Failure("Enter value");@Success);@Success)

You should now be able safely call a Source.Refresh method without inadvertently triggering validation rules until the data is ready.

此岸叶落 2024-12-15 11:14:58

我不确定是否有特定于 Lotus Notes 的解决方法,但在任何系统中都适用的一个技巧是在验证公式中进行另一项测试。不要只是说 @If(FieldName != ""; @Failure; @Success),而是添加另一个您可以控制的条件,例如 @If(DoValidation = "Yes" & FieldName ! =“”;@失败;@成功)。然后您可以通过控制 DoValidation 项的值来控制验证。

我经常将 @IsDocBeingSaved 添加到条件中,以便仅在保存文档时才会触发验证:

@If(@IsDocBeingSaved & FieldName != ""; @Failure; @Success)

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:

@If(@IsDocBeingSaved & FieldName != ""; @Failure; @Success)
煞人兵器 2024-12-15 11:14:58

考虑到 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 the ItemProductFamilyType item, sparing you the need to duplicate code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文