【问题标题】:Is this scenario possible?这种情况可能吗?
【发布时间】:2019-08-02 14:29:20
【问题描述】:

这种情况是否可以使用按钮以一种形式出现?

如果我创建新记录: 我的保存和关闭按钮将发送通知。

如果我编辑现有的现有记录: 我的保存和关闭按钮不会发送通知。

目前,我有 4 个按钮: 编辑、退出、保存和关闭。

当我点击新建时: 仅显示保存并关闭按钮。

当我打开现有的: 显示编辑和退出。然后当我点击编辑时,会出现保存并关闭。

**计划添加另一个保存和关闭按钮,我将在其中放置此代码。 然后只会在我处于创建新模式而不是编辑模式时显示。

Sub Click(Source As Button)
    Dim ses As New NotesSession
    Dim db As NotesDatabase 
    Dim doc As NotesDocument 
    Dim body As NotesRichtextItem
    ' get the database
    Set db = ses.CurrentDatabase
    ' create a new document in the database
    Set doc = New NotesDocument( db )
    ' set the new document's form so it'll be readable as a mail memo
    doc.Form = "Memo"
    ' set the new document's subject
    doc.Subject = "Notification"
    ' set the new document's body
    Set body = New NotesRichtextitem( doc, "Body" )
    Call body.AppendText( "A new record has been created." )
    Call body.AddNewLine(1)
    Call body.AppendText( "Click here to open the document --> " )  
    Call body.AppendDocLink( ws.CurrentDocument.document, "Click me" )
    'Call doc.Send( False, "Lekhwair Alatan")
    Dim recipients( 1 To 2 ) As String
    recipients( 1 ) = "recipient 1"
    recipients( 2 ) = "recipient 2"
    Call doc.Send( True, recipients )
End Sub

【问题讨论】:

    标签: lotus-notes lotus-domino lotusscript lotus lotus-formula


    【解决方案1】:

    所以我假设此代码位于操作栏按钮或 UI 表单上的另一个按钮中。

    因此,您可以从 NotesUIWorkspace 中获取 CurrentDocument(类型 NotesUIDocument),并从中检查属性 IsNewDoc。您还可以将发送通知的日期/时间另存为文档中的一个字段,这样您就可以随时返回并验证通知是否已发送。

    Dim workspace as New NotesUIWorkspace
    Dim docuiCurrent as NotesUIDocument
    
    set docuiCurrent = workspace.CurrentDocument
    
    if docuiCurrent.Document.HasItem( "$UpdatedBy" ) then
        // send notification
    End If
    

    【讨论】:

      【解决方案2】:

      将邮件发送功能的代码放在表单的保存后事件中。添加一个新字段以保存状态。

      简化版可能如下所示:

      dim mailSent as string
      mailSent = doc.getitemvalue("MailSent")(0)
      if len(mailSent)=0 then
       call sendMail(doc)
       call doc.replaceItemvalue("MailSent",cstr(now))
       call doc.save(true,false)
      end if

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-12
        • 1970-01-01
        • 2017-11-26
        • 1970-01-01
        • 1970-01-01
        • 2012-01-21
        • 1970-01-01
        • 2018-05-05
        相关资源
        最近更新 更多