验证 Richtext 字段中的附件

发布于 2024-10-12 06:08:26 字数 634 浏览 3 评论 0原文

我使用下面的代码来验证 Richtext 字段中的附件。

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

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

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

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

I am using below code to validate the Attachment in Richtext field.

If I will not used Call source.Refresh(True)
then validation is not working, but this code is also refreshing document everytime querysave is called in buttons.

So is there any option or any other idea so that I should not user this Refresh part or entire code to validate .

If anybody have more efficient code then please share this.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

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

There's a way in LotusScript to check attachments presence even for new (not saved) documents.

Create a hidden computed field, for instance AttachmentNames with formula:

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

In LotusScript do the following:

'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
云醉月微眠 2024-10-19 06:08:26

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

If(doc.HasEmbedded) Then Continue = True

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

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

Validating rich text fields in Lotus Notes is a bit of a dark art, but can you not just do this? (where doc is the back-end):

If(doc.HasEmbedded) Then Continue = True

There are other things you can do. Check this Lotus Developer Domain post, which covers attachments, text, embedded objects, all sorts:

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

故人的歌 2024-10-19 06:08:26

你能用公式验证 RT 字段吗?

我使用以下输入验证公式在富文本字段下方创建了一个隐藏字段:

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);

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);
猫性小仙女 2024-10-19 06:08:26

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

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

Assuming that you want to avoid the Refresh because it takes too long, here is what you may want to look at and if feasible, try to change:

  1. Maybe you can use the "Entering" event of the RichText field in conjunction with a global variable (in the form) to skip the Refresh in your code, if the RichText field wasn't touched at all.
  2. Are there keyword fields with "Refresh choices on document refresh" option enabled that may be safe to disable? Or even place a button that would bring up a dialog and populate the field with the selected keyword(s) - refreshing the choices won't be neccessary then, as you can always present up-to-date choices through @DbColumn/@DbLookup or NotesUIWorkspace.PickListStrings.
  3. Is there any code (LotusScript or Formula) in "Queryrecalc" and/or "Postrecalc" form events that may be possible to optimize? For example by using a global variable (in the form) as a flag whether to execute the code in Queryrecalc/Postrecalc - set it to false just before calling Refresh in your code, then set it back to true (because this Refresh only serves to update the RichText field to the backend document).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文