如何测试某个字段是否存在于 ui 文档中或隐藏有关它的 Notes 错误消息
How to test if a field exist in a ui document or hide a Notes error-message about it
我编写了一个代理来测试列表中的每个字段是否为空。字段可以是任何类型,包括 RichText。富文本字段可以包含文本或附件。代理必须是 UIDocument 上的 运行,因为如果 required 字段为空,则不允许用户保存。
我们有一个现有的代理,但它 return 有时(每天 5 或 6 次)错误“4602 : L'opération DOM Parser a échoué”(我认为它应该类似于"operation DOM Parser failed" 英文)在这一行:
Call DXLExporter.process
我在网上查到是服务器问题,我没办法处理。我发现了一些有趣的东西来替换现有的代理:
' source is the NotesUIDocument, send to the agent in parameter
' champSource is a string : the name of the field
On Error GoTo ErrorHandler
Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll
Exit Function
ErrorHandler:
Select Case Err
Case 4407 ' empty field
Print "champ vide : " & ChampSource
Case 4412 ' non-existent field
Print "champ non trouvé : " & ChampSource
Case Else
Print LSI_Info(2) & " - " & Error & " - " & Err & " - " & Erl
End Select
Exit Function
而且有效,如果字段为空,"source.DeselectAll" 会生成错误 4407,如果包含任何内容,则不会出现错误。
问题在于它是一个包含字段 "hidden when" 的表单。当测试其中一个字段时,如果它被隐藏,我会在这一行中得到一个 Notes 弹出窗口 "Impossible de localiser ce champ"(英文应该是 "impossible to locate this field"):
Call source.GoToField(ChampSource)
只有在此弹出窗口之后,脚本才会转到 ErrorHandler。
我试着在前面加个条件:
If source.Document.HasItem(ChampSource) Then
Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll
End If
但是尽管 ui 文档中不存在该字段,但该项目存在于文档中。
我正在寻找一种解决方案来隐藏 Notes 弹出窗口并让我的 ErrorHandler 完成他的工作或测试该字段是否存在于 ui 文档中。
提前感谢您的回答。
PS : 抱歉我的英语不好,我是法国人。
关于 dom 解析器错误。我的服务器上有同样的错误。而且我找到了两个有效的解决方案(大多数时候)。
- 重试几次。也就是说,如果错误 4602 然后再试一次。将最大重试次数设置为 10-20 次。我仍然看到这种方法的错误,但不像以前那么频繁了。
- 不验证。将 DOM 解析器上的 InputValidationOption 设置为 VALIDATE_NEVER。
您实际上要做的不是测试 source.Document.HasItem(ChampSource)
,而是查看表单并确定隐藏时间的公式是什么。然后你可以编写如下代码:
if Evaluate("The hide-when-formula goes here", source.Document) = true then
' the field is hidden; so do what you want for that case
else
Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll
end if
我编写了一个代理来测试列表中的每个字段是否为空。字段可以是任何类型,包括 RichText。富文本字段可以包含文本或附件。代理必须是 UIDocument 上的 运行,因为如果 required 字段为空,则不允许用户保存。
我们有一个现有的代理,但它 return 有时(每天 5 或 6 次)错误“4602 : L'opération DOM Parser a échoué”(我认为它应该类似于"operation DOM Parser failed" 英文)在这一行:
Call DXLExporter.process
我在网上查到是服务器问题,我没办法处理。我发现了一些有趣的东西来替换现有的代理:
' source is the NotesUIDocument, send to the agent in parameter
' champSource is a string : the name of the field
On Error GoTo ErrorHandler
Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll
Exit Function
ErrorHandler:
Select Case Err
Case 4407 ' empty field
Print "champ vide : " & ChampSource
Case 4412 ' non-existent field
Print "champ non trouvé : " & ChampSource
Case Else
Print LSI_Info(2) & " - " & Error & " - " & Err & " - " & Erl
End Select
Exit Function
而且有效,如果字段为空,"source.DeselectAll" 会生成错误 4407,如果包含任何内容,则不会出现错误。
问题在于它是一个包含字段 "hidden when" 的表单。当测试其中一个字段时,如果它被隐藏,我会在这一行中得到一个 Notes 弹出窗口 "Impossible de localiser ce champ"(英文应该是 "impossible to locate this field"):
Call source.GoToField(ChampSource)
只有在此弹出窗口之后,脚本才会转到 ErrorHandler。
我试着在前面加个条件:
If source.Document.HasItem(ChampSource) Then
Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll
End If
但是尽管 ui 文档中不存在该字段,但该项目存在于文档中。
我正在寻找一种解决方案来隐藏 Notes 弹出窗口并让我的 ErrorHandler 完成他的工作或测试该字段是否存在于 ui 文档中。
提前感谢您的回答。
PS : 抱歉我的英语不好,我是法国人。
关于 dom 解析器错误。我的服务器上有同样的错误。而且我找到了两个有效的解决方案(大多数时候)。
- 重试几次。也就是说,如果错误 4602 然后再试一次。将最大重试次数设置为 10-20 次。我仍然看到这种方法的错误,但不像以前那么频繁了。
- 不验证。将 DOM 解析器上的 InputValidationOption 设置为 VALIDATE_NEVER。
您实际上要做的不是测试 source.Document.HasItem(ChampSource)
,而是查看表单并确定隐藏时间的公式是什么。然后你可以编写如下代码:
if Evaluate("The hide-when-formula goes here", source.Document) = true then
' the field is hidden; so do what you want for that case
else
Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll
end if