0

我正在使用下面的代码来验证富文本字段中的附件。

如果我不使用 Call source.Refresh(True) 则验证不起作用,但是每次在按钮中调用 querysave 时,此代码也会刷新文档。

那么是否有任何选项或任何其他想法,以便我不应该使用此 Refresh 部分或整个代码来验证。

如果有人有更有效的代码,请分享。

If Source.Document.YesNo20(0)="Yes" Then
    Call source.Refresh(True)
    Dim rtitem As NotesRichTextItem
    Set rtitem = source.Document.GetFirstItem( "Atchmnt20" ) 
    NotesEmbeddedObjectArray = rtitem.EmbeddedObjects
    If Isempty ( NotesEmbeddedObjectArray ) Then 
        Messagebox "Please enter an attachment in 20a. As you selected option Yes"
        continue=False
        Exit Sub
    End If 
End If
4

4 回答 4

1

LotusScript 中有一种方法可以检查附件是否存在,即使是新的(未保存的)文档也是如此。

创建一个隐藏的计算域,例如AttachmentNames和公式:

@If(@AttachmentNames!=""; "1"; "");

在 LotusScript 中执行以下操作:

'in new documents Form field may be empty
If doc.Form(0) = "" then    
    doc.Form = "YourFormAlias"    
End If

'computing doc contents with the form
call doc.ComputeWithForm(false, false)

If doc.AttachmentNames(0) = "" then    
 MsgBox "Please attach a file",,"Attention"
 Continue = False 'if you are running this code in QuerySave
 Exit Sub
End If
于 2011-08-09T09:00:41.553 回答
0

假设您想避免刷新,因为它花费的时间太长,您可能想要查看以下内容,如果可行,请尝试更改:

  1. 如果完全没有触及 RichText 字段,也许您可​​以将 RichText 字段的“Entering”事件与全局变量(在表单中)结合使用来跳过代码中的 Refresh。
  2. 是否有启用了“在文档刷新时刷新选项”选项的关键字字段可以安全禁用?或者甚至放置一个按钮,该按钮会弹出一个对话框并使用选定的关键字填充字段 - 然后不需要刷新选择,因为您始终可以通过 @DbColumn/@DbLookup 呈现最新的选择或 NotesUIWorkspace.PickListStrings。
  3. “Queryrecalc”和/或“Postrecalc”表单事件中是否有任何代码(LotusScript 或公式)可以优化?例如,通过使用全局变量(在表单中)作为标志是否执行 Queryrecalc/Postrecalc 中的代码 - 在代码中调用 Refresh 之前将其设置为 false,然后将其设置回 true(因为此 Refresh 仅用于将 RichText 字段更新到后端文档)。
于 2011-03-14T20:55:38.717 回答
0

Can you validate RT field with formula?

I created a hidden field below my rich text field with this Input Validation formula:

REM {Validate just when saving};
@If(!@IsDocBeingSaved; @Return(@Success); "");

REM {Should contain some file};
_filenames := @AttachmentNames;
@If(
    @Elements(_filenames)=0;
    @Return(@Failure("You should attach at least one file"));
    @Success);
于 2011-03-11T15:22:24.777 回答
0

在 Lotus Notes 中验证富文本字段有点像一门黑暗的艺术,但您能不能不这样做?(doc后端在哪里):

If(doc.HasEmbedded) Then Continue = True

您还可以做其他事情。查看此 Lotus Developer Domain 帖子,其中涵盖附件、文本、嵌入对象等各种内容:

http://www-10.lotus.com/ldd/nd6forum.nsf/0/8b3df10667d355768525719a00549058

于 2011-01-17T10:17:05.493 回答